summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-22 12:05:42 (UTC)
committer zautrix <zautrix>2005-03-22 12:05:42 (UTC)
commit345c70e057e730850493689185b5c358607566f9 (patch) (unidiff)
tree5081ceed28a61012c1c4d2c7200205fdbedc6435 /korganizer
parentdfd7d8d53c7ab916dee820c2371195a5dce134a4 (diff)
downloadkdepimpi-345c70e057e730850493689185b5c358607566f9.zip
kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.gz
kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.bz2
more layout fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp83
-rw-r--r--korganizer/datenavigatorcontainer.h2
-rw-r--r--korganizer/kdatenavigator.h3
-rw-r--r--korganizer/kodaymatrix.cpp16
-rw-r--r--korganizer/kodaymatrix.h2
5 files changed, 82 insertions, 24 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 18756f0..bb27bce 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -46,6 +46,8 @@ DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
46 46
47 connectNavigatorView( mNavigatorView ); 47 connectNavigatorView( mNavigatorView );
48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 48 //setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
49 mDisplayedEndDate = QDate::currentDate();
50 mLastDisplayedDN = 0;
49} 51}
50 52
51DateNavigatorContainer::~DateNavigatorContainer() 53DateNavigatorContainer::~DateNavigatorContainer()
@@ -80,18 +82,18 @@ void DateNavigatorContainer::setCalendar( Calendar *cal )
80{ 82{
81 mCalendar = cal; 83 mCalendar = cal;
82 mNavigatorView->setCalendar( cal ); 84 mNavigatorView->setCalendar( cal );
83 KDateNavigator *n; 85 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
84 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 86 KDateNavigator *n = mExtraViews.at( i );
85 n->setCalendar( cal ); 87 n->setCalendar( cal );
86 } 88 }
87} 89}
88 90
89void DateNavigatorContainer::updateDayMatrix() 91void DateNavigatorContainer::updateDayMatrix()
90{ 92{
91 mNavigatorView->updateDayMatrix(); 93 mNavigatorView->updateDayMatrix();
92 KDateNavigator *n; 94 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
93 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 95 KDateNavigator *n = mExtraViews.at( i );
94 n->updateDayMatrix(); 96 n->updateDayMatrix();
95 } 97 }
96} 98}
97 99
@@ -110,30 +112,66 @@ void DateNavigatorContainer::updateToday()
110void DateNavigatorContainer::updateView() 112void DateNavigatorContainer::updateView()
111{ 113{
112 mNavigatorView->updateView(); 114 mNavigatorView->updateView();
113 KDateNavigator *n; 115 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
114 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 116 KDateNavigator *n = mExtraViews.at( i );
115 n->updateView(); 117 n->updateView();
116 } 118 }
117} 119}
118 120
119void DateNavigatorContainer::updateConfig() 121void DateNavigatorContainer::updateConfig()
120{ 122{
121 mNavigatorView->updateConfig(); 123 mNavigatorView->updateConfig();
122 KDateNavigator *n; 124 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
123 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 125 KDateNavigator *n = mExtraViews.at( i );
124 n->updateConfig(); 126 n->updateConfig();
125 } 127 }
126} 128}
127 129
128void DateNavigatorContainer::selectDates( const DateList &dateList ) 130void DateNavigatorContainer::selectDates( const DateList &dateList )
129{ 131{
130 mNavigatorView->selectDates( dateList ); 132 if ( !mLastDisplayedDN ) {
131 setBaseDates(); 133 mNavigatorView->selectDates( dateList );
132 if ( mExtraViews.count() ) { 134 return;
135 }
136 QDate fDate = dateList.first();
137 QDate lDate = dateList.last();
138 if ( mLastDisplayedDN <= 2 ) {
139 mNavigatorView->selectDates( dateList );
140 KDateNavigator *view = mExtraViews.at( 0 );
141 QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 );
142 view->setBaseDate( bDate, false );
143 view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
144 if ( mLastDisplayedDN == 2 ) {
145 view = mExtraViews.at( 1 );
146 bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 );
147 view->setBaseDate( bDate, false );
148 view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
149 }
150 return;
151 }
152 KDateNavigator *view = mExtraViews.at( 0 );
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() );
157 if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
158 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
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;
167 }
168 mNavigatorView->selectDates( dateList );
169 setBaseDates();
170 if ( mLastDisplayedDN ) {
133 KDateNavigator *view = mExtraViews.at( 0 ); 171 KDateNavigator *view = mExtraViews.at( 0 );
134 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 172 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
135 view->dayMatrix()->repaint( false ); 173 view->dayMatrix()->repaint( false );
136 if ( mExtraViews.count() > 1 ) { 174 if ( mLastDisplayedDN > 1 ) {
137 KDateNavigator *view = mExtraViews.at( 1 ); 175 KDateNavigator *view = mExtraViews.at( 1 );
138 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); 176 view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
139 view->dayMatrix()->repaint( false ); 177 view->dayMatrix()->repaint( false );
@@ -148,9 +186,9 @@ void DateNavigatorContainer::setBaseDates()
148 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl; 186 kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
149 } 187 }
150 QDate baseDate = dateList.first(); 188 QDate baseDate = dateList.first();
151 KDateNavigator *n;
152 bool doRepaint = false; // skip first repaint 189 bool doRepaint = false; // skip first repaint
153 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 190 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
191 KDateNavigator *n = mExtraViews.at( i );
154 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 ); 192 baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
155 n->setBaseDate( baseDate, doRepaint ); 193 n->setBaseDate( baseDate, doRepaint );
156 doRepaint = true; 194 doRepaint = true;
@@ -211,12 +249,14 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
211 } 249 }
212 } 250 }
213 251
252 mLastDisplayedDN = horizontalCount*verticalCount-1;
253 bool setBaseD = false;
214 while ( count > ( mExtraViews.count() + 1 ) ) { 254 while ( count > ( mExtraViews.count() + 1 ) ) {
215 KDateNavigator *n = new KDateNavigator( this ); 255 KDateNavigator *n = new KDateNavigator( this );
216 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 256 n->setMonthSignalOffset ( mExtraViews.count()+1 );
217 mExtraViews.append( n ); 257 mExtraViews.append( n );
218 n->setCalendar( mCalendar ); 258 n->setCalendar( mCalendar );
219 setBaseDates(); 259 setBaseD = true;
220 connectNavigatorView( n ); 260 connectNavigatorView( n );
221 n->show(); 261 n->show();
222 } 262 }
@@ -228,6 +268,8 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
228 mExtraViews.at( iii )->hide(); 268 mExtraViews.at( iii )->hide();
229 ++iii; 269 ++iii;
230 } 270 }
271 if ( setBaseD )
272 setBaseDates();
231 if ( fontchange ) { 273 if ( fontchange ) {
232 //mNavigatorView->changeFont( fo ); 274 //mNavigatorView->changeFont( fo );
233 uint i; 275 uint i;
@@ -238,6 +280,7 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
238 } 280 }
239 mHorizontalCount = horizontalCount; 281 mHorizontalCount = horizontalCount;
240 mVerticalCount = verticalCount; 282 mVerticalCount = verticalCount;
283
241 } 284 }
242 //qDebug("COUNT %d ", mExtraViews.count()); 285 //qDebug("COUNT %d ", mExtraViews.count());
243 int height = size().height() / verticalCount; 286 int height = size().height() / verticalCount;
@@ -249,7 +292,7 @@ void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
249 292
250 mNavigatorView->setGeometry(0, 293 mNavigatorView->setGeometry(0,
251 0, width, height ); 294 0, width, height );
252 for( uint i = 0; i < mExtraViews.count(); ++i ) { 295 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
253 int x = ( i + 1 ) % horizontalCount; 296 int x = ( i + 1 ) % horizontalCount;
254 int y = ( i + 1 ) / horizontalCount; 297 int y = ( i + 1 ) / horizontalCount;
255 298
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index affa8e1..f45af20 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -77,6 +77,8 @@ class DateNavigatorContainer: public QWidget
77 void connectNavigatorView( KDateNavigator *v ); 77 void connectNavigatorView( KDateNavigator *v );
78 78
79 private: 79 private:
80 int mLastDisplayedDN;
81 QDate mDisplayedEndDate;
80 KDateNavigator *mNavigatorView; 82 KDateNavigator *mNavigatorView;
81 83
82 KCal::Calendar *mCalendar; 84 KCal::Calendar *mCalendar;
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
index 10bc1be..93bbceb 100644
--- a/korganizer/kdatenavigator.h
+++ b/korganizer/kdatenavigator.h
@@ -61,6 +61,9 @@ class KDateNavigator: public QFrame
61 void setShowWeekNums( bool enabled ); 61 void setShowWeekNums( bool enabled );
62 void setCalendar( Calendar * ); 62 void setCalendar( Calendar * );
63 void setBaseDate( const QDate & , bool doRepaint = true ); 63 void setBaseDate( const QDate & , bool doRepaint = true );
64
65 QDate baseDate() const { return m_MthYr;}
66
64 KCal::DateList selectedDates() const { return mSelectedDates; } 67 KCal::DateList selectedDates() const { return mSelectedDates; }
65 NavigatorBar *navigatorBar() const { return mNavigatorBar; } 68 NavigatorBar *navigatorBar() const { return mNavigatorBar; }
66 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;} 69 void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index a2e0ae0..3ee1fa7 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -284,15 +284,22 @@ void KODayMatrix::addSelectedDaysTo(DateList& selDays)
284 } 284 }
285} 285}
286 286
287void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 287bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
288{ 288{
289 bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
289 mSelStart = startdate.daysTo(start); 290 mSelStart = startdate.daysTo(start);
290 if ( mSelStart < 0 ) 291 if ( mSelStart < 0 )
291 mSelStart = 0; 292 mSelStart = 0;
292 mSelEnd = startdate.daysTo(end); 293 mSelEnd = startdate.daysTo(end);
293 //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd ); 294 if ( mSelEnd > NUMDAYS-1 )
294 if ( mSelEnd < 0 ) 295 mSelEnd = NUMDAYS-1;
296 if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
295 clearSelection(); 297 clearSelection();
298 if ( noSel )
299 return false;
300 }
301
302 return true;
296} 303}
297void KODayMatrix::clearSelection() 304void KODayMatrix::clearSelection()
298{ 305{
@@ -699,6 +706,8 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
699 startMo = 1; 706 startMo = 1;
700 if ( endMo == 1 && mo == 12 ) 707 if ( endMo == 1 && mo == 12 )
701 endMo = 12; 708 endMo = 12;
709 if ( mo == 12 && startMo == 1 )
710 startMo = 13;
702 if ( (startMo > mo || endMo < mo) ) { 711 if ( (startMo > mo || endMo < mo) ) {
703 skip = true; 712 skip = true;
704 } else { 713 } else {
@@ -712,6 +721,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
712 } 721 }
713 } 722 }
714 } 723 }
724 //qDebug("SKIP %d ", skip);
715 if ( ! skip ) { 725 if ( ! skip ) {
716 row = mSelStartT/7; 726 row = mSelStartT/7;
717 col = mSelStartT -row*7; 727 col = mSelStartT -row*7;
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 10f4b05..2a1959c 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -154,7 +154,7 @@ public:
154 * start and ending with end. Theview must be manually updated by calling 154 * start and ending with end. Theview must be manually updated by calling
155 * repaint. (?) 155 * repaint. (?)
156 */ 156 */
157 void setSelectedDaysFrom(const QDate& start, const QDate& end); 157 bool setSelectedDaysFrom(const QDate& start, const QDate& end);
158 void clearSelection(); 158 void clearSelection();
159 159
160 /** Is today visible in the view? Keep this in sync with 160 /** Is today visible in the view? Keep this in sync with