summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (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
@@ -130,41 +130,152 @@ void DateNavigatorContainer::slotMonthSelected( int month )
}
}
void DateNavigatorContainer::setCalendar( Calendar *cal )
{
mCalendar = cal;
mNavigatorView->setCalendar( cal );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
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;
QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
if ( selFirst >= first && selLast <= last ) {
updateDayMatrixDates();
}
else {
updateDayMatrixDates();
emit monthSelected( mFirstSelectedDate.month() );
}
}
void DateNavigatorContainer::updateDayMatrixDates()
{
- mUpdateTimer->stop();
QDate fDate = mFirstSelectedDate;
QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
mNavigatorView->dayMatrix()->repaint( false );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
n->dayMatrix()->repaint( false );
}
}
}
@@ -260,132 +371,29 @@ void DateNavigatorContainer::setBaseDates()
{
QDate baseDate = mNavigatorView->baseDate();
bool doRepaint = true;
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
n->setBaseDate( baseDate, doRepaint );
}
}
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
{
return mNavigatorView->minimumSizeHint();
}
QSize DateNavigatorContainer::sizeHint() const
{
return mNavigatorView->yourSizeHint();
}