summaryrefslogtreecommitdiffabout
path: root/korganizer/datenavigatorcontainer.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/datenavigatorcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp83
1 files changed, 63 insertions, 20 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 18756f0..bb27bce 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -48,2 +48,4 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
//setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
+ mDisplayedEndDate = QDate::currentDate();
+ mLastDisplayedDN = 0;
}
@@ -82,5 +84,5 @@ void DateNavigatorContainer::setCalendar( Calendar *cal )
mNavigatorView->setCalendar( cal );
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->setCalendar( cal );
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->setCalendar( cal );
}
@@ -91,5 +93,5 @@ void DateNavigatorContainer::updateDayMatrix()
mNavigatorView->updateDayMatrix();
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->updateDayMatrix();
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->updateDayMatrix();
}
@@ -112,5 +114,5 @@ void DateNavigatorContainer::updateView()
mNavigatorView->updateView();
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->updateView();
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->updateView();
}
@@ -121,5 +123,5 @@ void DateNavigatorContainer::updateConfig()
mNavigatorView->updateConfig();
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->updateConfig();
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->updateConfig();
}
@@ -129,5 +131,41 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
{
- mNavigatorView->selectDates( dateList );
- setBaseDates();
- if ( mExtraViews.count() ) {
+ 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;
+ }
+ KDateNavigator *view = mExtraViews.at( 0 );
+ QDate date = view->baseDate();
+
+ QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
+ //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
+ if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
+ 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 );
+ }
+ }
+ return;
+ }
+ mNavigatorView->selectDates( dateList );
+ setBaseDates();
+ if ( mLastDisplayedDN ) {
KDateNavigator *view = mExtraViews.at( 0 );
@@ -135,3 +173,3 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
view->dayMatrix()->repaint( false );
- if ( mExtraViews.count() > 1 ) {
+ if ( mLastDisplayedDN > 1 ) {
KDateNavigator *view = mExtraViews.at( 1 );
@@ -150,5 +188,5 @@ void DateNavigatorContainer::setBaseDates()
QDate baseDate = dateList.first();
- KDateNavigator *n;
bool doRepaint = false; // skip first repaint
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
@@ -213,2 +251,4 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
+ mLastDisplayedDN = horizontalCount*verticalCount-1;
+ bool setBaseD = false;
while ( count > ( mExtraViews.count() + 1 ) ) {
@@ -218,3 +258,3 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
n->setCalendar( mCalendar );
- setBaseDates();
+ setBaseD = true;
connectNavigatorView( n );
@@ -230,2 +270,4 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
}
+ if ( setBaseD )
+ setBaseDates();
if ( fontchange ) {
@@ -240,2 +282,3 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
mVerticalCount = verticalCount;
+
}
@@ -251,3 +294,3 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
0, width, height );
- for( uint i = 0; i < mExtraViews.count(); ++i ) {
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
int x = ( i + 1 ) % horizontalCount;