Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/datenavigatorcontainer.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp index 9720146..ba97fa6 100644 --- a/korganizer/datenavigatorcontainer.cpp +++ b/korganizer/datenavigatorcontainer.cpp @@ -44,12 +44,15 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent, mNavigatorView = new KDateNavigator( this, name ); connectNavigatorView( mNavigatorView ); //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); mLastDisplayedDN = 0; + mUpdateTimer; + mUpdateTimer = new QTimer( this ); + connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() )); } DateNavigatorContainer::~DateNavigatorContainer() { } @@ -132,15 +135,30 @@ void DateNavigatorContainer::setCalendar( Calendar *cal ) mNavigatorView->setCalendar( cal ); for( uint i = 0; i < mLastDisplayedDN; ++i ) { KDateNavigator *n = mExtraViews.at( i ); n->setCalendar( cal ); } } +void DateNavigatorContainer::checkUpdateDayMatrixDates() +{ + 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 ); @@ -215,26 +233,12 @@ void DateNavigatorContainer::selectDates( const DateList &dateList ) if ( !mLastDisplayedDN ) { mNavigatorView->selectDates( dateList ); return; } QDate fDate = dateList.first(); QDate lDate = dateList.last(); - if ( mLastDisplayedDN <= 2 ) { - mNavigatorView->selectDates( dateList ); - KDateNavigator *view = mExtraViews.at( 0 ); - QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 ); - view->setBaseDate( bDate, false ); - view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); - if ( mLastDisplayedDN == 2 ) { - view = mExtraViews.at( 1 ); - bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 ); - view->setBaseDate( bDate, false ); - view->dayMatrix()->setSelectedDaysFrom(fDate , lDate); - } - return; - } //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() ); //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) { updateDayMatrixDates(); return; } @@ -369,12 +373,13 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e ) if ( x + 1 == horizontalCount ) bar->showButtons( false, true ); else bar->showButtons( false, false ); } view->setGeometry( x * width, y * height, width, height ); } + mUpdateTimer->start( 250 ); //updateDayMatrixDates(); } QSize DateNavigatorContainer::minimumSizeHint() const { return mNavigatorView->minimumSizeHint(); |