summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-30 13:46:29 (UTC)
committer zautrix <zautrix>2005-03-30 13:46:29 (UTC)
commit8c160d7aeeab1d22382ced11440712f6541a6db7 (patch) (unidiff)
tree83fd0df6d30db6bbb05d82dc400d6f51823f5b3a /korganizer
parent056f171723a9301aea5a65340dffeda34e078abf (diff)
downloadkdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.zip
kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.tar.gz
kdepimpi-8c160d7aeeab1d22382ced11440712f6541a6db7.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index f6f62a4..92abae6 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -71,261 +71,271 @@ void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
71#endif 71#endif
72 connect( v, SIGNAL( weekClicked( const QDate & ) ), 72 connect( v, SIGNAL( weekClicked( const QDate & ) ),
73 SIGNAL( weekClicked( const QDate & ) ) ); 73 SIGNAL( weekClicked( const QDate & ) ) );
74 connect( v, SIGNAL( showMonth( const QDate & ) ), 74 connect( v, SIGNAL( showMonth( const QDate & ) ),
75 SIGNAL( showMonth( const QDate & ) ) ); 75 SIGNAL( showMonth( const QDate & ) ) );
76 76
77 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) ); 77 connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
78 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) ); 78 connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
79 79
80 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) ); 80 connect( v, SIGNAL( goNextMonth() ), SLOT( slotgoNextMonth() ) );
81 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) ); 81 connect( v, SIGNAL( goPrevMonth() ), SLOT( slotgoPrevMonth() ) );
82 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) ); 82 connect( v, SIGNAL( goNextYear() ), SLOT( slotgoNextYear() ) );
83 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) ); 83 connect( v, SIGNAL( goPrevYear() ), SLOT( slotgoPrevYear() ) );
84 84
85 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); 85 connect( v, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) );
86} 86}
87void DateNavigatorContainer::slotgoNextYear() 87void DateNavigatorContainer::slotgoNextYear()
88{ 88{
89 jumpMonth( 12 ); 89 jumpMonth( 12 );
90 emit goNextYear(); 90 emit goNextYear();
91 91
92} 92}
93void DateNavigatorContainer::slotgoPrevYear() 93void DateNavigatorContainer::slotgoPrevYear()
94{ 94{
95 jumpMonth( -12 ); 95 jumpMonth( -12 );
96 emit goPrevYear(); 96 emit goPrevYear();
97 97
98} 98}
99void DateNavigatorContainer::slotgoPrevMonth() 99void DateNavigatorContainer::slotgoPrevMonth()
100{ 100{
101 jumpMonth( -1 ); 101 jumpMonth( -1 );
102 emit goPrevMonth(); 102 emit goPrevMonth();
103 103
104} 104}
105void DateNavigatorContainer::slotgoNextMonth() 105void DateNavigatorContainer::slotgoNextMonth()
106{ 106{
107 jumpMonth( 1 ); 107 jumpMonth( 1 );
108 emit goNextMonth(); 108 emit goNextMonth();
109} 109}
110void DateNavigatorContainer::jumpMonth( int month ) 110void DateNavigatorContainer::jumpMonth( int month )
111{ 111{
112 112
113 QDate baseDate = mNavigatorView->baseDate(); 113 QDate baseDate = mNavigatorView->baseDate();
114 computeMonthSelected( baseDate.month() + month, false ); 114 computeMonthSelected( baseDate.month() + month, false );
115} 115}
116void DateNavigatorContainer::slotMonthSelected( int month ) 116void DateNavigatorContainer::slotMonthSelected( int month )
117{ 117{
118 computeMonthSelected( month, true ); 118 computeMonthSelected( month, true );
119} 119}
120void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit ) 120void DateNavigatorContainer::computeMonthSelected( int month , bool forceEmit )
121{ 121{
122 //qDebug("slotMonthSelected %d ", month); 122 //qDebug("slotMonthSelected %d ", month);
123 QDate baseDate = mNavigatorView->baseDate(); 123 QDate baseDate = mNavigatorView->baseDate();
124 if ( baseDate.month() == month ) 124 if ( baseDate.month() == month )
125 return; 125 return;
126 //qDebug("month %d %d ",baseDate.month(),month); 126 //qDebug("month %d %d ",baseDate.month(),month);
127 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 ); 127 QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
128 date = date.addDays( -(baseDate.month()-month ) *30 ); 128 date = date.addDays( -(baseDate.month()-month ) *30 );
129 QDate newBase = QDate ( date.year(), date.month() ,1 ); 129 QDate newBase = QDate ( date.year(), date.month() ,1 );
130 130
131 //qDebug("NEW BASE %s", newBase.toString().latin1()); 131 //qDebug("NEW BASE %s", newBase.toString().latin1());
132 mNavigatorView->setBaseDate( newBase ); 132 mNavigatorView->setBaseDate( newBase );
133 QDate last = lastAvailableDate(); 133 QDate last = lastAvailableDate();
134 QDate first = firstAvailableDate(); 134 QDate first = firstAvailableDate();
135 135
136 QDate selFirst = mFirstSelectedDate; 136 QDate selFirst = mFirstSelectedDate;
137 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 137 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
138 if ( selFirst >= first && selLast <= last ) { 138 if ( selFirst >= first && selLast <= last ) {
139 setBaseDates(); 139 setBaseDates();
140 if ( forceEmit ) 140 if ( forceEmit )
141 updateDayMatrixDates(); 141 updateDayMatrixDates();
142 } 142 }
143 else { 143 else {
144 setBaseDates(); 144 setBaseDates();
145 if ( forceEmit ) 145 if ( forceEmit )
146 updateDayMatrixDates(); 146 updateDayMatrixDates();
147 if ( forceEmit ) 147 if ( forceEmit )
148 emit monthSelected( month ); 148 emit monthSelected( month );
149 } 149 }
150} 150}
151void DateNavigatorContainer::setCalendar( Calendar *cal ) 151void DateNavigatorContainer::setCalendar( Calendar *cal )
152{ 152{
153 mCalendar = cal; 153 mCalendar = cal;
154 mNavigatorView->setCalendar( cal ); 154 mNavigatorView->setCalendar( cal );
155 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 155 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
156 KDateNavigator *n = mExtraViews.at( i ); 156 KDateNavigator *n = mExtraViews.at( i );
157 n->setCalendar( cal ); 157 n->setCalendar( cal );
158 } 158 }
159} 159}
160void DateNavigatorContainer::checkUpdateDayMatrixDates() 160void DateNavigatorContainer::checkUpdateDayMatrixDates()
161{ 161{
162 //qDebug("KODNC: wid %d hei %d ", width(), height()); 162 //qDebug("KODNC: wid %d hei %d ", width(), height());
163 mUpdateTimer->stop(); 163 mUpdateTimer->stop();
164 //return; 164 //return;
165 if ( width() < 3 || height() < 3 ) 165 if ( width() < 3 || height() < 3 )
166 return; 166 return;
167 static int lastWid = 0; 167 static int lastWid = 0;
168 static int lastHei = 0; 168 static int lastHei = 0;
169 if ( lastWid == width() && height() == lastHei ) { 169 if ( lastWid == width() && height() == lastHei ) {
170 qDebug("KODNC: No layout computing needed. "); 170 qDebug("KODNC: No layout computing needed. ");
171 } else { 171 } else {
172 lastWid = width(); 172 lastWid = width();
173 lastHei = height(); 173 lastHei = height();
174 174
175 QSize minSize = mNavigatorView->yourSizeHint(); 175 QSize minSize = mNavigatorView->yourSizeHint();
176 176
177 int verticalCount = size().height() / minSize.height(); 177 int verticalCount = size().height() / minSize.height();
178 int horizontalCount = size().width() / minSize.width(); 178 int horizontalCount = size().width() / minSize.width();
179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() ); 179 //qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount ); 180 //qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
181 bool fontchange = false; 181 bool fontchange = false;
182 if ( horizontalCount == 1) 182 if ( horizontalCount == 1)
183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width(); 183 horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
184 QFont fo; 184 QFont fo;
185 if ( horizontalCount != mHorizontalCount || 185 if ( horizontalCount != mHorizontalCount ||
186 verticalCount != mVerticalCount ) { 186 verticalCount != mVerticalCount ) {
187 uint count = horizontalCount * verticalCount; 187 uint count = horizontalCount * verticalCount;
188 if ( count == 0 ) { 188 if ( count == 0 ) {
189 bool ok; 189 bool ok;
190 fo = mNavigatorView->yourFontHint( size() , &ok ); 190 fo = mNavigatorView->yourFontHint( size() , &ok );
191 //mNavigatorView->resize( size() ); 191 //mNavigatorView->resize( size() );
192 //if ( ! ok ) 192 //if ( ! ok )
193 // return; 193 // return;
194 int butt = 2; 194 int butt = 2;
195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width(); 195 horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
196 if ( horizontalCount <= 1 ) 196 if ( horizontalCount <= 1 )
197 minSize = mNavigatorView->sizeHintTwoButtons( 4 ); 197 minSize = mNavigatorView->sizeHintTwoButtons( 4 );
198 else 198 else
199 minSize = mNavigatorView->sizeHintTwoButtons(); 199 minSize = mNavigatorView->sizeHintTwoButtons();
200 verticalCount = size().height() / minSize.height(); 200 verticalCount = size().height() / minSize.height();
201 horizontalCount = size().width() / minSize.width(); 201 horizontalCount = size().width() / minSize.width();
202 if ( horizontalCount == 0 ) 202 if ( horizontalCount == 0 )
203 horizontalCount = 1; 203 horizontalCount = 1;
204 if ( verticalCount == 0 ) 204 if ( verticalCount == 0 )
205 verticalCount = 1; 205 verticalCount = 1;
206 fontchange = true; 206 fontchange = true;
207 count = horizontalCount * verticalCount; 207 count = horizontalCount * verticalCount;
208 } 208 } else {
209 209 if ( mNavigatorView->fontChanged() ) {
210 fontchange = true;
211 fo = KOPrefs::instance()->mDateNavigatorFont;
212 mNavigatorView->changeFont( fo );
213 mNavigatorView->unsetFontChanged();
214 }
215 }
210 mLastDisplayedDN = horizontalCount*verticalCount-1; 216 mLastDisplayedDN = horizontalCount*verticalCount-1;
211 while ( count > ( mExtraViews.count() + 1 ) ) { 217 while ( count > ( mExtraViews.count() + 1 ) ) {
212 KDateNavigator *n = new KDateNavigator( this ); 218 KDateNavigator *n = new KDateNavigator( this );
213 n->setMonthSignalOffset ( mExtraViews.count()+1 ); 219 n->setMonthSignalOffset ( mExtraViews.count()+1 );
214 mExtraViews.append( n ); 220 mExtraViews.append( n );
215 n->setCalendar( mCalendar ); 221 n->setCalendar( mCalendar );
216 connectNavigatorView( n ); 222 connectNavigatorView( n );
217 // n->show(); 223 // n->show();
218 } 224 }
219 225
220 setBaseDates(); 226 setBaseDates();
227 if ( fontchange ) {
228 //mNavigatorView->changeFont( fo );
229 uint i;
230 for( i = 0; i < mExtraViews.count(); ++i ) {
231 KDateNavigator *view = mExtraViews.at( i );
232 view->changeFont( fo );
233 }
234 }
221 mHorizontalCount = horizontalCount; 235 mHorizontalCount = horizontalCount;
222 mVerticalCount = verticalCount; 236 mVerticalCount = verticalCount;
223 237
224 } 238 }
225 if ( !fontchange ) { 239 if ( mNavigatorView->fontChanged() && ! fontchange ) {
226 if ( mNavigatorView->fontChanged() ) { 240 qDebug("KDNC: Resetting all fonts ");
227 fontchange = true; 241 fo = KOPrefs::instance()->mDateNavigatorFont;
228 fo = KOPrefs::instance()->mDateNavigatorFont; 242 mNavigatorView->changeFont( fo );
229 mNavigatorView->changeFont( fo ); 243 mNavigatorView->unsetFontChanged();
230 mNavigatorView->unsetFontChanged();
231 }
232 }
233 if ( fontchange ) {
234 uint i; 244 uint i;
235 for( i = 0; i < mLastDisplayedDN; ++i ) { 245 for( i = 0; i < mExtraViews.count(); ++i ) {
236 KDateNavigator *view = mExtraViews.at( i ); 246 KDateNavigator *view = mExtraViews.at( i );
237 view->changeFont( fo ); 247 view->changeFont( fo );
238 } 248 }
239 } 249 }
240 int theight = height() / mVerticalCount; 250 int theight = height() / mVerticalCount;
241 int twidth = width() / mHorizontalCount; 251 int twidth = width() / mHorizontalCount;
242 252
243 NavigatorBar *bar = mNavigatorView->navigatorBar(); 253 NavigatorBar *bar = mNavigatorView->navigatorBar();
244 if ( mHorizontalCount > 1 ) bar->showButtons( true, false ); 254 if ( mHorizontalCount > 1 ) bar->showButtons( true, false );
245 else bar->showButtons( true, true ); 255 else bar->showButtons( true, true );
246 256
247 mNavigatorView->setGeometry(0, 257 mNavigatorView->setGeometry(0,
248 0, twidth, theight ); 258 0, twidth, theight );
249 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 259 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
250 int x = ( i + 1 ) % mHorizontalCount; 260 int x = ( i + 1 ) % mHorizontalCount;
251 int y = ( i + 1 ) / mHorizontalCount; 261 int y = ( i + 1 ) / mHorizontalCount;
252 262
253 KDateNavigator *view = mExtraViews.at( i ); 263 KDateNavigator *view = mExtraViews.at( i );
254 bar = view->navigatorBar(); 264 bar = view->navigatorBar();
255 if ( y > 0 ) bar->showButtons( false, false ); 265 if ( y > 0 ) bar->showButtons( false, false );
256 else { 266 else {
257 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true ); 267 if ( x + 1 == mHorizontalCount ) bar->showButtons( false, true );
258 else bar->showButtons( false, false ); 268 else bar->showButtons( false, false );
259 } 269 }
260 view->setGeometry( x * twidth, 270 view->setGeometry( x * twidth,
261 y * theight, twidth, theight ); 271 y * theight, twidth, theight );
262 } 272 }
263 int iii = 0; 273 int iii = 0;
264 int ccc = mHorizontalCount * mVerticalCount; 274 int ccc = mHorizontalCount * mVerticalCount;
265 mNavigatorView->show(); 275 mNavigatorView->show();
266 while ( iii < ( mExtraViews.count() ) ) { 276 while ( iii < ( mExtraViews.count() ) ) {
267 if ( iii < ccc-1 ) 277 if ( iii < ccc-1 )
268 mExtraViews.at( iii )->show(); 278 mExtraViews.at( iii )->show();
269 else 279 else
270 mExtraViews.at( iii )->hide(); 280 mExtraViews.at( iii )->hide();
271 ++iii; 281 ++iii;
272 } 282 }
273 } 283 }
274 284
275 QDate last = lastAvailableDate(); 285 QDate last = lastAvailableDate();
276 QDate first = firstAvailableDate(); 286 QDate first = firstAvailableDate();
277 287
278 QDate selFirst = mFirstSelectedDate; 288 QDate selFirst = mFirstSelectedDate;
279 QDate selLast = selFirst.addDays( mSelectedDateCount-1 ); 289 QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
280 if ( selFirst >= first && selLast <= last ) { 290 if ( selFirst >= first && selLast <= last ) {
281 updateDayMatrixDates(); 291 updateDayMatrixDates();
282 } 292 }
283 else { 293 else {
284 updateDayMatrixDates(); 294 updateDayMatrixDates();
285 emit monthSelected( mFirstSelectedDate.month() ); 295 emit monthSelected( mFirstSelectedDate.month() );
286 } 296 }
287} 297}
288void DateNavigatorContainer::updateDayMatrixDates() 298void DateNavigatorContainer::updateDayMatrixDates()
289{ 299{
290 QDate fDate = mFirstSelectedDate; 300 QDate fDate = mFirstSelectedDate;
291 QDate lDate = fDate.addDays( mSelectedDateCount - 1 ); 301 QDate lDate = fDate.addDays( mSelectedDateCount - 1 );
292 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate ); 302 mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
293 mNavigatorView->dayMatrix()->repaint( false ); 303 mNavigatorView->dayMatrix()->repaint( false );
294 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 304 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
295 KDateNavigator *n = mExtraViews.at( i ); 305 KDateNavigator *n = mExtraViews.at( i );
296 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) { 306 if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
297 n->dayMatrix()->repaint( false ); 307 n->dayMatrix()->repaint( false );
298 } 308 }
299 } 309 }
300} 310}
301 311
302void DateNavigatorContainer::updateDayMatrix() 312void DateNavigatorContainer::updateDayMatrix()
303{ 313{
304 mNavigatorView->updateDayMatrix(); 314 mNavigatorView->updateDayMatrix();
305 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 315 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
306 KDateNavigator *n = mExtraViews.at( i ); 316 KDateNavigator *n = mExtraViews.at( i );
307 n->updateDayMatrix(); 317 n->updateDayMatrix();
308 } 318 }
309} 319}
310 320
311void DateNavigatorContainer::updateToday() 321void DateNavigatorContainer::updateToday()
312{ 322{
313 qDebug("DateNavigatorContainer::updateToday() NOT IMPL "); 323 qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
314#if 0 324#if 0
315 mNavigatorView->updateToday(); 325 mNavigatorView->updateToday();
316 KDateNavigator *n; 326 KDateNavigator *n;
317 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) { 327 for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
318 n->updateToday(); 328 n->updateToday();
319 } 329 }
320#endif 330#endif
321} 331}
322 332
323void DateNavigatorContainer::updateView() 333void DateNavigatorContainer::updateView()
324{ 334{
325 mNavigatorView->updateView(); 335 mNavigatorView->updateView();
326 for( uint i = 0; i < mLastDisplayedDN; ++i ) { 336 for( uint i = 0; i < mLastDisplayedDN; ++i ) {
327 KDateNavigator *n = mExtraViews.at( i ); 337 KDateNavigator *n = mExtraViews.at( i );
328 n->updateView(); 338 n->updateView();
329 } 339 }
330} 340}
331 341