summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp114
-rw-r--r--korganizer/datenavigatorcontainer.h7
-rw-r--r--korganizer/kdatenavigator.cpp1
3 files changed, 98 insertions, 24 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index bb27bce..6de7c45 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -48,3 +48,2 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49 mDisplayedEndDate = QDate::currentDate();
50 mLastDisplayedDN = 0; 49 mLastDisplayedDN = 0;
@@ -77,5 +76,54 @@ void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
77 76
78 connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) ); 77 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
79} 78}
80 79
80void DateNavigatorContainer::slotMonthSelected( int month )
81{
82 //qDebug("slotMonthSelected %d ", month);
83 QDate baseDate = mNavigatorView->baseDate();
84 if ( baseDate.month() == month )
85 return;
86 //qDebug("month %d %d ",baseDate.month(),month);
87 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
88 date = date.addDays( -(baseDate.month()-month ) *30 );
89 QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
90
91#if 0
92 mFirstSelectedDate = dateList.first() ;
93 mSelectedDateCount = dateList.count() ;
94
95 KDateNavigator *view = mExtraViews.at( 0 );
96 QDate date = view->baseDate();
97
98 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
99 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
100 if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
101 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
102 mNavigatorView->dayMatrix()->repaint( false );
103 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
104 KDateNavigator *n = mExtraViews.at( i );
105 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
106 n->dayMatrix()->repaint( false );
107 }
108 }
109 return;
110 }
111#endif
112 //qDebug("NEW BASE %s", newBase.toString().latin1());
113 mNavigatorView->setBaseDate( newBase );
114 QDate last = lastAvailableDate();
115 QDate first = firstAvailableDate();
116
117 QDate selFirst = mFirstSelectedDate;
118 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
119 if ( selFirst >= first && selLast <= last ) {
120 setBaseDates();
121 updateDayMatrixDates();
122 }
123 else {
124 setBaseDates();
125 updateDayMatrixDates();
126 emit monthSelected( month );
127 }
128}
81void DateNavigatorContainer::setCalendar( Calendar *cal ) 129void DateNavigatorContainer::setCalendar( Calendar *cal )
@@ -89,2 +137,16 @@ void DateNavigatorContainer::setCalendar( Calendar *cal )
89} 137}
138void DateNavigatorContainer::updateDayMatrixDates()
139{
140
141 QDate fDate = mFirstSelectedDate;
142 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
143 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
144 mNavigatorView->dayMatrix()->repaint( false );
145 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
146 KDateNavigator *n = mExtraViews.at( i );
147 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
148 n->dayMatrix()->repaint( false );
149 }
150 }
151}
90 152
@@ -128,5 +190,26 @@ void DateNavigatorContainer::updateConfig()
128} 190}
129 191QDate DateNavigatorContainer::lastAvailableDate() const
192{
193 QDate date = mNavigatorView->baseDate();
194 QDate last = QDate ( date.year(), date.month(), date.daysInMonth() );
195 int iii = mLastDisplayedDN;
196 if ( mLastDisplayedDN )
197 last = last.addDays( 1);
198 while ( iii ) {
199 last = last.addDays( last.daysInMonth ());
200 //qDebug("DATE %s ", last.toString().latin1() );
201 --iii;
202 }
203 if ( mLastDisplayedDN )
204 last = last.addDays( -1);
205 return last;
206}
207QDate DateNavigatorContainer::firstAvailableDate() const
208{
209 return QDate ( mNavigatorView->baseDate().year(), mNavigatorView->baseDate().month(), 1 );
210}
130void DateNavigatorContainer::selectDates( const DateList &dateList ) 211void DateNavigatorContainer::selectDates( const DateList &dateList )
131{ 212{
213 mFirstSelectedDate = dateList.first() ;
214 mSelectedDateCount = dateList.count() ;
132 if ( !mLastDisplayedDN ) { 215 if ( !mLastDisplayedDN ) {
@@ -151,16 +234,6 @@ void DateNavigatorContainer::selectDates( const DateList &dateList )
151 } 234 }
152 KDateNavigator *view = mExtraViews.at( 0 ); 235 //qDebug("%s %s ", lastAvailableDate().toString().latin1(), firstAvailableDate().toString().latin1() );
153 QDate date = view->baseDate();
154
155 QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
156 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() ); 236 //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
157 if ( lDate < curEnd && date.addDays( -30 ) < fDate) { 237 if ( lDate <= lastAvailableDate() && firstAvailableDate() <= fDate) {
158 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 238 updateDayMatrixDates();
159 mNavigatorView->dayMatrix()->repaint( false );
160 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
161 KDateNavigator *n = mExtraViews.at( i );
162 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
163 n->dayMatrix()->repaint( false );
164 }
165 }
166 return; 239 return;
@@ -183,8 +256,4 @@ void DateNavigatorContainer::setBaseDates()
183{ 256{
184 KCal::DateList dateList = mNavigatorView->selectedDates(); 257 QDate baseDate = mNavigatorView->baseDate();
185 if ( dateList.isEmpty() ) { 258 bool doRepaint = true;
186 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
187 }
188 QDate baseDate = dateList.first();
189 bool doRepaint = false; // skip first repaint
190 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 259 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
@@ -193,3 +262,2 @@ void DateNavigatorContainer::setBaseDates()
193 n->setBaseDate( baseDate, doRepaint ); 262 n->setBaseDate( baseDate, doRepaint );
194 doRepaint = true;
195 } 263 }
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index f45af20..d5e5adf 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -48,2 +48,4 @@ class DateNavigatorContainer: public QWidget
48 KDateNavigator * navigatorView() { return mNavigatorView;} 48 KDateNavigator * navigatorView() { return mNavigatorView;}
49 QDate lastAvailableDate() const ;
50 QDate firstAvailableDate() const ;
49 51
@@ -54,3 +56,5 @@ class DateNavigatorContainer: public QWidget
54 void updateDayMatrix(); 56 void updateDayMatrix();
57 void updateDayMatrixDates();
55 void updateToday(); 58 void updateToday();
59 void slotMonthSelected( int month );
56 60
@@ -80,3 +84,4 @@ class DateNavigatorContainer: public QWidget
80 int mLastDisplayedDN; 84 int mLastDisplayedDN;
81 QDate mDisplayedEndDate; 85 QDate mFirstSelectedDate;
86 int mSelectedDateCount;
82 KDateNavigator *mNavigatorView; 87 KDateNavigator *mNavigatorView;
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 231095f..83a57ca 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -192,2 +192,3 @@ void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true
192 m_MthYr = date; 192 m_MthYr = date;
193 //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1());
193 194