summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp24
-rw-r--r--korganizer/koagendaitem.h1
-rw-r--r--korganizer/koagendaview.cpp2
3 files changed, 11 insertions, 16 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 9fe1be4..abb29f7 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -155,578 +155,574 @@ void KOAgendaItem::init ( Incidence *incidence, QDate qd )
155 mSelected = true; 155 mSelected = true;
156 select(false); 156 select(false);
157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 157 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
158 mFontPixelSize = fontinf.height();; 158 mFontPixelSize = fontinf.height();;
159 hide(); 159 hide();
160 xPaintCoord = -1; 160 xPaintCoord = -1;
161 yPaintCoord = -1; 161 yPaintCoord = -1;
162} 162}
163 163
164 164
165KOAgendaItem::~KOAgendaItem() 165KOAgendaItem::~KOAgendaItem()
166{ 166{
167#if QT_VERSION >= 0x030000 167#if QT_VERSION >= 0x030000
168 168
169#else 169#else
170 delete mKOAgendaItemWhatsThis; 170 delete mKOAgendaItemWhatsThis;
171#endif 171#endif
172 172
173} 173}
174 174
175void KOAgendaItem::recreateIncidence() 175void KOAgendaItem::recreateIncidence()
176{ 176{
177#if 0 177#if 0
178 Incidence* newInc = mIncidence->clone(); 178 Incidence* newInc = mIncidence->clone();
179 newInc->recreate(); 179 newInc->recreate();
180 if ( mIncidence->doesRecur() ) { 180 if ( mIncidence->doesRecur() ) {
181 mIncidence->addExDate( mDate ); 181 mIncidence->addExDate( mDate );
182 newInc->recurrence()->unsetRecurs(); 182 newInc->recurrence()->unsetRecurs();
183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd()); 183 int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
184 QTime tim = mIncidence->dtStart().time(); 184 QTime tim = mIncidence->dtStart().time();
185 newInc->setDtStart( QDateTime(mDate, tim) ); 185 newInc->setDtStart( QDateTime(mDate, tim) );
186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
187 } 187 }
188#endif 188#endif
189 mIncidence = mIncidence->recreateCloneException( mDate ); 189 mIncidence = mIncidence->recreateCloneException( mDate );
190} 190}
191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) 191bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
192{ 192{
193 int size = AGENDA_ICON_SIZE; 193 int size = AGENDA_ICON_SIZE;
194 194
195 int yOff = 0; 195 int yOff = 0;
196 int xOff = 0; 196 int xOff = 0;
197 int x = pos().x(); 197 int x = pos().x();
198 198
199 if ( x < 0 ) x = 0; 199 if ( x < 0 ) x = 0;
200 x += 3; 200 x += 3;
201 int y; 201 int y;
202 if ( mAllDay ) 202 if ( mAllDay )
203 y = pos().y()+3; 203 y = pos().y()+3;
204 else 204 else
205 y = mCellYTop * ( height() / cellHeight() ) +3; 205 y = mCellYTop * ( height() / cellHeight() ) +3;
206 206
207 207
208 if ( mIncidence->calID() > 1 ) { 208 if ( mIncidence->calID() > 1 ) {
209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 209 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
210 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 ); 210 p->drawRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x-1, yOff*( 1 +AGENDA_ICON_SIZE)+y-1, AGENDA_ICON_SIZE+2, AGENDA_ICON_SIZE+2 );
211 if ( horLayout ){ 211 if ( horLayout ){
212 ++xOff; 212 ++xOff;
213 ++x; 213 ++x;
214 } 214 }
215 else { 215 else {
216 ++yOff; 216 ++yOff;
217 ++y; 217 ++y;
218 } 218 }
219 } 219 }
220 if (mIncidence->cancelled() && height() < 20 ) { 220 if (mIncidence->cancelled() && height() < 20 ) {
221 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x; 221 int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
222 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y; 222 int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
223 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 ); 223 p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
224 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos ); 224 p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
225 if ( horLayout ) 225 if ( horLayout )
226 ++xOff; 226 ++xOff;
227 else 227 else
228 ++yOff; 228 ++yOff;
229 } 229 }
230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) { 230 if (mIncidence->isAlarmEnabled() && mIncidence->alarmEnabled()) {
231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red ); 231 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, red );
232 if ( horLayout ) 232 if ( horLayout )
233 ++xOff; 233 ++xOff;
234 else 234 else
235 ++yOff; 235 ++yOff;
236 } 236 }
237 if (mIncidence->recurrence()->doesRecur()) { 237 if (mIncidence->recurrence()->doesRecur()) {
238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue ); 238 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, blue );
239 if ( horLayout ) 239 if ( horLayout )
240 ++xOff; 240 ++xOff;
241 else 241 else
242 ++yOff; 242 ++yOff;
243 } 243 }
244 if (mIncidence->description().length() > 0) { 244 if (mIncidence->description().length() > 0) {
245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen ); 245 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkGreen );
246 if ( horLayout ) 246 if ( horLayout )
247 ++xOff; 247 ++xOff;
248 else 248 else
249 ++yOff; 249 ++yOff;
250 } 250 }
251 if (mIncidence->isReadOnly()) { 251 if (mIncidence->isReadOnly()) {
252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white ); 252 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, white );
253 if ( horLayout ) 253 if ( horLayout )
254 ++xOff; 254 ++xOff;
255 else 255 else
256 ++yOff; 256 ++yOff;
257 } 257 }
258 258
259 if (mIncidence->attendeeCount()>0) { 259 if (mIncidence->attendeeCount()>0) {
260 260
261 if (mIncidence->organizer() == KOPrefs::instance()->email()) { 261 if (mIncidence->organizer() == KOPrefs::instance()->email()) {
262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black ); 262 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, black );
263 if ( horLayout ) 263 if ( horLayout )
264 ++xOff; 264 ++xOff;
265 else 265 else
266 ++yOff; 266 ++yOff;
267 } else { 267 } else {
268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 268 Attendee *me = mIncidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
269 if (me!=0) { 269 if (me!=0) {
270 270
271 271
272 } else { 272 } else {
273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow ); 273 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, yellow );
274 if ( horLayout ) 274 if ( horLayout )
275 ++xOff; 275 ++xOff;
276 else 276 else
277 ++yOff; 277 ++yOff;
278 278
279 } 279 }
280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); 280 p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow );
281 if ( horLayout ) 281 if ( horLayout )
282 ++xOff; 282 ++xOff;
283 else 283 else
284 ++yOff; 284 ++yOff;
285 285
286 } 286 }
287 287
288 } 288 }
289 return ( yOff || xOff ); 289 return ( yOff || xOff );
290} 290}
291 291
292 292
293void KOAgendaItem::select(bool selected) 293void KOAgendaItem::select(bool selected)
294{ 294{
295 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); 295 //qDebug("select %d %d",firstMultiItem(), nextMultiItem() );
296 if (mSelected == selected) return; 296 if (mSelected == selected) return;
297 mSelected = selected; 297 mSelected = selected;
298 if ( ! isVisible() ) 298 if ( ! isVisible() )
299 return; 299 return;
300 if ( firstMultiItem() ) 300 if ( firstMultiItem() )
301 firstMultiItem()->select( selected ); 301 firstMultiItem()->select( selected );
302 if ( !firstMultiItem() && nextMultiItem() ) { 302 if ( !firstMultiItem() && nextMultiItem() ) {
303 KOAgendaItem * placeItem = nextMultiItem(); 303 KOAgendaItem * placeItem = nextMultiItem();
304 while ( placeItem ) { 304 while ( placeItem ) {
305 placeItem->select( selected ); 305 placeItem->select( selected );
306 placeItem = placeItem->nextMultiItem(); 306 placeItem = placeItem->nextMultiItem();
307 } 307 }
308 } 308 }
309 globalFlagBlockAgendaItemUpdate = 0; 309 globalFlagBlockAgendaItemUpdate = 0;
310 paintMe( selected ); 310 paintMe( selected );
311 globalFlagBlockAgendaItemUpdate = 1; 311 globalFlagBlockAgendaItemUpdate = 1;
312 repaint( false ); 312 repaint( false );
313} 313}
314 314
315 315
316/* 316/*
317 The eventFilter has to filter the mouse events of the agenda item childs. The 317 The eventFilter has to filter the mouse events of the agenda item childs. The
318 events are fed into the event handling method of KOAgendaItem. This allows the 318 events are fed into the event handling method of KOAgendaItem. This allows the
319 KOAgenda to handle the KOAgendaItems by using an eventFilter. 319 KOAgenda to handle the KOAgendaItems by using an eventFilter.
320*/ 320*/
321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) 321bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
322{ 322{
323 if (e->type() == QEvent::MouseButtonPress || 323 if (e->type() == QEvent::MouseButtonPress ||
324 e->type() == QEvent::MouseButtonDblClick || 324 e->type() == QEvent::MouseButtonDblClick ||
325 e->type() == QEvent::MouseButtonRelease || 325 e->type() == QEvent::MouseButtonRelease ||
326 e->type() == QEvent::MouseMove) { 326 e->type() == QEvent::MouseMove) {
327 QMouseEvent *me = (QMouseEvent *)e; 327 QMouseEvent *me = (QMouseEvent *)e;
328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> 328 QPoint itemPos = this->mapFromGlobal(((QWidget *)object)->
329 mapToGlobal(me->pos())); 329 mapToGlobal(me->pos()));
330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); 330 QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state());
331 return event(&returnEvent); 331 return event(&returnEvent);
332 } else { 332 } else {
333 return false; 333 return false;
334 } 334 }
335} 335}
336void KOAgendaItem::repaintMe( ) 336void KOAgendaItem::repaintMe( )
337{ 337{
338 paintMe ( mSelected ); 338 paintMe ( mSelected );
339} 339}
340void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 340void KOAgendaItem::paintMe( bool selected, QPainter* paint )
341{ 341{
342 if ( globalFlagBlockAgendaItemUpdate && ! selected) 342 if ( globalFlagBlockAgendaItemUpdate && ! selected)
343 return; 343 return;
344 QPainter pa; 344 QPainter pa;
345 345
346 if ( mSelected ) { 346 if ( mSelected ) {
347 pa.begin( paintPixSel() ); 347 pa.begin( this );
348 } else { 348 } else {
349 if ( mAllDay ) 349 if ( mAllDay )
350 pa.begin( paintPixAllday() ); 350 pa.begin( paintPixAllday() );
351 else 351 else
352 pa.begin( paintPix() ); 352 pa.begin( paintPix() );
353 } 353 }
354 int x, yy, w, h; 354 int x, yy, w, h;
355 float nfh = 7.0; 355 float nfh = 7.0;
356 x = pos().x(); w = width(); h = height (); 356 x = pos().x(); w = width(); h = height ();
357 if ( mAllDay ) 357 if ( mAllDay )
358 yy = y(); 358 yy = y();
359 else 359 else
360 yy = mCellYTop * ( height() / cellHeight() ); 360 yy = mCellYTop * ( height() / cellHeight() );
361 if ( mSelected ) {
362 pa.translate( -x, -yy );
363 }
361 xPaintCoord= x; 364 xPaintCoord= x;
362 yPaintCoord = yy; 365 yPaintCoord = yy;
363 wPaintCoord = width(); 366 wPaintCoord = width();
364 hPaintCoord = height(); 367 hPaintCoord = height();
365 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
366 if ( paint == 0 ) 369 if ( paint == 0 )
367 paint = &pa; 370 paint = &pa;
368 bool horLayout = ( w < h ); 371 bool horLayout = ( w < h );
369 int maxhei = mFontPixelSize+4; 372 int maxhei = mFontPixelSize+4;
370 if ( horLayout ) 373 if ( horLayout )
371 maxhei += AGENDA_ICON_SIZE -4; 374 maxhei += AGENDA_ICON_SIZE -4;
372 bool small = ( h < maxhei ); 375 bool small = ( h < maxhei );
373 if ( ! small ) 376 if ( ! small )
374 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 377 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
375 else { 378 else {
376 QFont f = KOPrefs::instance()->mAgendaViewFont; 379 QFont f = KOPrefs::instance()->mAgendaViewFont;
377 f.setBold( false ); 380 f.setBold( false );
378 int fh = f.pointSize(); 381 int fh = f.pointSize();
379 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 382 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
380 if ( nfh < 6 ) 383 if ( nfh < 6 )
381 nfh = 6; 384 nfh = 6;
382 f.setPointSize( nfh ); 385 f.setPointSize( nfh );
383 paint->setFont(f); 386 paint->setFont(f);
384 } 387 }
385 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 388 paint->fillRect ( x, yy, w, h, mBackgroundColor );
386 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 389 static const QPixmap completedPxmp = SmallIcon("greenhook16");
387 static const QPixmap overduePxmp = SmallIcon("redcross16"); 390 static const QPixmap overduePxmp = SmallIcon("redcross16");
388 if ( mIncidence->typeID() == todoID ) { 391 if ( mIncidence->typeID() == todoID ) {
389 Todo* tempTodo = static_cast<Todo*>(mIncidence); 392 Todo* tempTodo = static_cast<Todo*>(mIncidence);
390 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 393 int xx = pos().x()+(width()-completedPxmp.width()-3 );
391 int yyy = yy+3; 394 int yyy = yy+3;
392 if ( tempTodo->isCompleted() ) 395 if ( tempTodo->isCompleted() )
393 paint->drawPixmap ( xx, yyy, completedPxmp ); 396 paint->drawPixmap ( xx, yyy, completedPxmp );
394 else { 397 else {
395 paint->drawPixmap ( xx, yyy, overduePxmp ); 398 paint->drawPixmap ( xx, yyy, overduePxmp );
396 399
397 } 400 }
398 } 401 }
399 bool addIcon = false; 402 bool addIcon = false;
400 if ( ! small || w > 3 * h || h > 3* w ) 403 if ( ! small || w > 3 * h || h > 3* w )
401 addIcon = updateIcons( paint, horLayout ); 404 addIcon = updateIcons( paint, horLayout );
402 405
403 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
404 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
405 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
406 if ( ! small ) { 409 if ( ! small ) {
407 x += 3; yy += 3;w -= 6; h-= 5; 410 x += 3; yy += 3;w -= 6; h-= 5;
408 } else { 411 } else {
409 x += 2; yy += 1;w -= 4; h-= 4; 412 x += 2; yy += 1;w -= 4; h-= 4;
410 if ( nfh < 6.01 ) { 413 if ( nfh < 6.01 ) {
411 yy -= 2; 414 yy -= 2;
412 h += 4; 415 h += 4;
413 } 416 }
414 else 417 else
415 if ( nfh < h -2 ) 418 if ( nfh < h -2 )
416 ++yy; 419 ++yy;
417 } 420 }
418 int align; 421 int align;
419#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
420 align = ( AlignLeft|WordBreak|AlignTop); 423 align = ( AlignLeft|WordBreak|AlignTop);
421#else 424#else
422 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
423#endif 426#endif
424 if ( addIcon ) { 427 if ( addIcon ) {
425 if ( ! horLayout ) { 428 if ( ! horLayout ) {
426 x += AGENDA_ICON_SIZE+3; 429 x += AGENDA_ICON_SIZE+3;
427 w -= (AGENDA_ICON_SIZE+3); 430 w -= (AGENDA_ICON_SIZE+3);
428 } 431 }
429 else { 432 else {
430 yy+= AGENDA_ICON_SIZE+2; 433 yy+= AGENDA_ICON_SIZE+2;
431 h -=(AGENDA_ICON_SIZE+3); 434 h -=(AGENDA_ICON_SIZE+3);
432 } 435 }
433 } 436 }
434 if ( mWhiteText ) 437 if ( mWhiteText )
435 paint->setPen ( white); 438 paint->setPen ( white);
436 if ( x < 0 ) { 439 if ( x < 0 ) {
437 w = w+x-3; 440 w = w+x-3;
438 x = 3; 441 x = 3;
439 if ( !horLayout && addIcon ) 442 if ( !horLayout && addIcon )
440 x += AGENDA_ICON_SIZE+3; 443 x += AGENDA_ICON_SIZE+3;
441 if ( w > parentWidget()->width() ){ 444 if ( w > parentWidget()->width() ){
442 w = parentWidget()->width() - 6; 445 w = parentWidget()->width() - 6;
443#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
444 align = ( AlignHCenter|WordBreak|AlignTop); 447 align = ( AlignHCenter|WordBreak|AlignTop);
445#else 448#else
446 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
447#endif 450#endif
448 451
449 } 452 }
450 } 453 }
451 QRect dr; 454 QRect dr;
452 if ( w + x > parentWidget()->width() ) 455 if ( w + x > parentWidget()->width() )
453 w = parentWidget()->width()-x; 456 w = parentWidget()->width()-x;
454 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
455 //qDebug("%d %d %d %d ", x, yy, w, h ); 458 //qDebug("%d %d %d %d ", x, yy, w, h );
456 if ( mIncidence->cancelled() ){ 459 if ( mIncidence->cancelled() ){
457 460
458 461
459 small = ( height() < 20 ); 462 small = ( height() < 20 );
460 463
461 if ( ! small ) { 464 if ( ! small ) {
462 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
463 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
464 } 467 }
465 468
466 } 469 }
467 pa.end(); 470 pa.end();
468 471
469} 472}
470void KOAgendaItem::resizePixmap( int w , int h ) 473void KOAgendaItem::resizePixmap( int w , int h )
471{ 474{
472 paintPix()->resize( w, h ); 475 paintPix()->resize( w, h );
473 paintPixSel()->resize( w, h );
474 476
475} 477}
476QPixmap * KOAgendaItem::paintPix() 478QPixmap * KOAgendaItem::paintPix()
477{ 479{
478 static QPixmap* mPaintPix = 0; 480 static QPixmap* mPaintPix = 0;
479 if ( ! mPaintPix ) { 481 if ( ! mPaintPix ) {
480 int w = QApplication::desktop()->width(); 482 int w = QApplication::desktop()->width();
481 int h = QApplication::desktop()->height(); 483 int h = QApplication::desktop()->height();
482 mPaintPix = new QPixmap(w,h); 484 mPaintPix = new QPixmap(w,h);
483 } 485 }
484 return mPaintPix ; 486 return mPaintPix ;
485} 487}
486QPixmap * KOAgendaItem::paintPixAllday() 488QPixmap * KOAgendaItem::paintPixAllday()
487{ 489{
488 static QPixmap* mPaintPixA = 0; 490 static QPixmap* mPaintPixA = 0;
489 if ( ! mPaintPixA ) { 491 if ( ! mPaintPixA ) {
490 int w = QApplication::desktop()->width(); 492 int w = QApplication::desktop()->width();
491 int h = QApplication::desktop()->height()/3; 493 int h = QApplication::desktop()->height()/3;
492 mPaintPixA = new QPixmap(w,h); 494 mPaintPixA = new QPixmap(w,h);
493 } 495 }
494 return mPaintPixA ; 496 return mPaintPixA ;
495} 497}
496QPixmap * KOAgendaItem::paintPixSel() 498
497{
498 static QPixmap* mPaintPixSel = 0;
499 if ( ! mPaintPixSel ) {
500 int w = QApplication::desktop()->width();
501 int h = QApplication::desktop()->height();
502 mPaintPixSel = new QPixmap(w,h);
503 }
504 return mPaintPixSel ;
505}
506void KOAgendaItem::paintEvent ( QPaintEvent *e ) 499void KOAgendaItem::paintEvent ( QPaintEvent *e )
507{ 500{
508 501
509 if ( globalFlagBlockAgendaItemPaint ) 502 if ( globalFlagBlockAgendaItemPaint )
510 return; 503 return;
511 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 504 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
512 return; 505 return;
513 int yy; 506 int yy;
514 if ( mAllDay ) 507 if ( mAllDay )
515 yy = y(); 508 yy = y();
516 else 509 else
517 yy = mCellYTop * ( height() / cellHeight() ); 510 yy = mCellYTop * ( height() / cellHeight() );
518 int xx = x(); 511 int xx = x();
519 512
520 if ( xPaintCoord != xx || yPaintCoord != yy || 513 if ( xPaintCoord != xx || yPaintCoord != yy ||
521 wPaintCoord != width() || hPaintCoord != height()) { 514 wPaintCoord != width() || hPaintCoord != height()) {
522 xPaintCoord= xx; 515 xPaintCoord= xx;
523 yPaintCoord = yy; 516 yPaintCoord = yy;
524 wPaintCoord = width(); 517 wPaintCoord = width();
525 hPaintCoord = height(); 518 hPaintCoord = height();
526 globalFlagBlockAgendaItemUpdate = 0; 519 globalFlagBlockAgendaItemUpdate = 0;
527 paintMe( mSelected ); 520 paintMe( mSelected );
528 //qDebug("calling paintMe "); 521 //qDebug("calling paintMe ");
529 globalFlagBlockAgendaItemUpdate = 1; 522 globalFlagBlockAgendaItemUpdate = 1;
523 if ( mSelected )
524 return;
530 } 525 }
531 int rx, ry, rw, rh; 526 int rx, ry, rw, rh;
532 rx = e->rect().x(); 527 rx = e->rect().x();
533 ry = e->rect().y(); 528 ry = e->rect().y();
534 rw = e->rect().width(); 529 rw = e->rect().width();
535 rh = e->rect().height(); 530 rh = e->rect().height();
536 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 531 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
537 532
538 QPixmap* paintFrom ; 533 QPixmap* paintFrom ;
539 if ( mSelected ) { 534 if ( mSelected ) {
540 paintFrom = paintPixSel(); 535 paintMe( mSelected );
536 return;
541 } else { 537 } else {
542 if ( mAllDay ) 538 if ( mAllDay )
543 paintFrom = paintPixAllday(); 539 paintFrom = paintPixAllday();
544 else 540 else
545 paintFrom = paintPix(); 541 paintFrom = paintPix();
546 } 542 }
547 xx += rx; 543 xx += rx;
548 544
549 if ( xx < 0 ) { 545 if ( xx < 0 ) {
550 rw = rw + xx; 546 rw = rw + xx;
551 rx -= xx; 547 rx -= xx;
552 xx = 0; 548 xx = 0;
553 if ( rw <= 1 ) { 549 if ( rw <= 1 ) {
554 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 550 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
555 return; 551 return;
556 } 552 }
557 } 553 }
558 if ( paintFrom->width() < xx+rw ) { 554 if ( paintFrom->width() < xx+rw ) {
559 rw = paintFrom->width() - xx; 555 rw = paintFrom->width() - xx;
560 if ( rw <= 1 ) { 556 if ( rw <= 1 ) {
561 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 557 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
562 return; 558 return;
563 } 559 }
564 } 560 }
565 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 561 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
566 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 562 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
567} 563}
568void KOAgendaItem::computeText() 564void KOAgendaItem::computeText()
569{ 565{
570 mDisplayedText = mIncidence->summary(); 566 mDisplayedText = mIncidence->summary();
571 if ( (mIncidence->typeID() == todoID ) ) { 567 if ( (mIncidence->typeID() == todoID ) ) {
572 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 568 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
573 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 569 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
574 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 570 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
575 else if ( !(mIncidence->doesFloat())) 571 else if ( !(mIncidence->doesFloat()))
576 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 572 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
577 } 573 }
578 } else { 574 } else {
579 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 575 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
580 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 576 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
581 577
582 if ( mAllDay ) { 578 if ( mAllDay ) {
583 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 579 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
584 if ( mIncidence->doesRecur() ) { 580 if ( mIncidence->doesRecur() ) {
585 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 581 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
586 } else { 582 } else {
587 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 583 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
588 } 584 }
589 } 585 }
590 } 586 }
591 } 587 }
592 588
593 if ( !mIncidence->location().isEmpty() ) { 589 if ( !mIncidence->location().isEmpty() ) {
594 if ( mAllDay ) 590 if ( mAllDay )
595 mDisplayedText += " ("; 591 mDisplayedText += " (";
596 else 592 else
597 mDisplayedText += "\n("; 593 mDisplayedText += "\n(";
598 mDisplayedText += mIncidence->location() +")"; 594 mDisplayedText += mIncidence->location() +")";
599 } 595 }
600#ifdef DESKTOP_VERSION 596#ifdef DESKTOP_VERSION
601 QString tipText = mIncidence->summary(); 597 QString tipText = mIncidence->summary();
602 if ( !mIncidence->doesFloat() ) { 598 if ( !mIncidence->doesFloat() ) {
603 if ( mIncidence->typeID() == eventID ) { 599 if ( mIncidence->typeID() == eventID ) {
604 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 600 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
605 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 601 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
606 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 602 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
607 } 603 }
608 else { 604 else {
609 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 605 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
610 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 606 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
611 } 607 }
612 } 608 }
613 else if ( mIncidence->typeID() == todoID ) { 609 else if ( mIncidence->typeID() == todoID ) {
614 if (mIncidence->hasStartDate()) 610 if (mIncidence->hasStartDate())
615 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 611 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
616 if (((Todo*)mIncidence)->hasDueDate()) 612 if (((Todo*)mIncidence)->hasDueDate())
617 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 613 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
618 } 614 }
619 } else if ( mIncidence->typeID() == todoID ) { 615 } else if ( mIncidence->typeID() == todoID ) {
620 if (mIncidence->hasStartDate()) 616 if (mIncidence->hasStartDate())
621 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 617 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
622 if (((Todo*)mIncidence)->hasDueDate()) 618 if (((Todo*)mIncidence)->hasDueDate())
623 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 619 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
624 } 620 }
625 621
626 if (!mIncidence->location().isEmpty()) { 622 if (!mIncidence->location().isEmpty()) {
627 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 623 tipText += "\n"+i18n("Location: ")+mIncidence->location();
628 } 624 }
629 QToolTip::add(this,tipText,toolTipGroup(),""); 625 QToolTip::add(this,tipText,toolTipGroup(),"");
630#endif 626#endif
631} 627}
632void KOAgendaItem::updateItem() 628void KOAgendaItem::updateItem()
633{ 629{
634 computeText(); 630 computeText();
635 631
636 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 632 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
637 paintMe( mSelected ); 633 paintMe( mSelected );
638 repaint( false); 634 repaint( false);
639} 635}
640 636
641void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 637void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
642{ 638{
643 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 639 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
644 paintMe( mSelected ); 640 paintMe( mSelected );
645 repaint( false ); 641 repaint( false );
646} 642}
647 643
648/* 644/*
649 Return height of item in units of agenda cells 645 Return height of item in units of agenda cells
650*/ 646*/
651int KOAgendaItem::cellHeight() 647int KOAgendaItem::cellHeight()
652{ 648{
653 int ret = mCellYBottom - mCellYTop + 1; 649 int ret = mCellYBottom - mCellYTop + 1;
654 if ( ret <= 0 ) { 650 if ( ret <= 0 ) {
655 ret = 1; 651 ret = 1;
656 mCellYBottom = 0; 652 mCellYBottom = 0;
657 mCellYTop = 0; 653 mCellYTop = 0;
658 } 654 }
659 return ret; 655 return ret;
660} 656}
661 657
662/* 658/*
663 Return height of item in units of agenda cells 659 Return height of item in units of agenda cells
664*/ 660*/
665int KOAgendaItem::cellWidth() 661int KOAgendaItem::cellWidth()
666{ 662{
667 return mCellXWidth - mCellX + 1; 663 return mCellXWidth - mCellX + 1;
668} 664}
669 665
670void KOAgendaItem::setItemDate(QDate qd) 666void KOAgendaItem::setItemDate(QDate qd)
671{ 667{
672 mDate = qd; 668 mDate = qd;
673} 669}
674 670
675void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 671void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
676{ 672{
677 mCellX = X; 673 mCellX = X;
678 mCellYTop = YTop; 674 mCellYTop = YTop;
679 mCellYBottom = YBottom; 675 mCellYBottom = YBottom;
680} 676}
681 677
682void KOAgendaItem::setCellXWidth(int xwidth) 678void KOAgendaItem::setCellXWidth(int xwidth)
683{ 679{
684 mCellXWidth = xwidth; 680 mCellXWidth = xwidth;
685} 681}
686 682
687void KOAgendaItem::setCellX(int XLeft, int XRight) 683void KOAgendaItem::setCellX(int XLeft, int XRight)
688{ 684{
689 mCellX = XLeft; 685 mCellX = XLeft;
690 mCellXWidth = XRight; 686 mCellXWidth = XRight;
691} 687}
692 688
693void KOAgendaItem::setCellY(int YTop, int YBottom) 689void KOAgendaItem::setCellY(int YTop, int YBottom)
694{ 690{
695 mCellYTop = YTop; 691 mCellYTop = YTop;
696 mCellYBottom = YBottom; 692 mCellYBottom = YBottom;
697} 693}
698 694
699void KOAgendaItem::setSubCell(int subCell) 695void KOAgendaItem::setSubCell(int subCell)
700{ 696{
701 mSubCell = subCell; 697 mSubCell = subCell;
702} 698}
703 699
704void KOAgendaItem::setSubCells(int subCells) 700void KOAgendaItem::setSubCells(int subCells)
705{ 701{
706 mSubCells = subCells; 702 mSubCells = subCells;
707} 703}
708 704
709void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 705void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
710 KOAgendaItem *last) 706 KOAgendaItem *last)
711{ 707{
712 mFirstMultiItem = first; 708 mFirstMultiItem = first;
713 mNextMultiItem = next; 709 mNextMultiItem = next;
714 mLastMultiItem = last; 710 mLastMultiItem = last;
715} 711}
716 712
717void KOAgendaItem::startMove() 713void KOAgendaItem::startMove()
718{ 714{
719 mStartCellX = mCellX; 715 mStartCellX = mCellX;
720 mStartCellXWidth = mCellXWidth; 716 mStartCellXWidth = mCellXWidth;
721 mStartCellYTop = mCellYTop; 717 mStartCellYTop = mCellYTop;
722 mStartCellYBottom = mCellYBottom; 718 mStartCellYBottom = mCellYBottom;
723} 719}
724 720
725void KOAgendaItem::resetMove() 721void KOAgendaItem::resetMove()
726{ 722{
727 mCellX = mStartCellX; 723 mCellX = mStartCellX;
728 mCellXWidth = mStartCellXWidth; 724 mCellXWidth = mStartCellXWidth;
729 mCellYTop = mStartCellYTop; 725 mCellYTop = mStartCellYTop;
730 mCellYBottom = mStartCellYBottom; 726 mCellYBottom = mStartCellYBottom;
731} 727}
732 728
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index dc2316a..7103abe 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,166 +1,165 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static void resizePixmap( int, int ); 104 static void resizePixmap( int, int );
105 static QPixmap * paintPix(); 105 static QPixmap * paintPix();
106 static QPixmap * paintPixSel();
107 static QPixmap * paintPixAllday(); 106 static QPixmap * paintPixAllday();
108 void updateItem(); 107 void updateItem();
109 void computeText(); 108 void computeText();
110 void recreateIncidence(); 109 void recreateIncidence();
111 bool checkLayout(); 110 bool checkLayout();
112 void initColor (); 111 void initColor ();
113 public slots: 112 public slots:
114 bool updateIcons( QPainter *, bool ); 113 bool updateIcons( QPainter *, bool );
115 void select(bool=true); 114 void select(bool=true);
116 115
117 protected: 116 protected:
118 void dragEnterEvent(QDragEnterEvent *e); 117 void dragEnterEvent(QDragEnterEvent *e);
119 void dropEvent(QDropEvent *e); 118 void dropEvent(QDropEvent *e);
120 void paintEvent ( QPaintEvent * ); 119 void paintEvent ( QPaintEvent * );
121 void resizeEvent ( QResizeEvent *ev ); 120 void resizeEvent ( QResizeEvent *ev );
122 121
123 private: 122 private:
124 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 123 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
125 bool mAllDay; 124 bool mAllDay;
126 bool mWhiteText; 125 bool mWhiteText;
127 int mCellX; 126 int mCellX;
128 int mCellXWidth; 127 int mCellXWidth;
129 int mCellYTop,mCellYBottom; 128 int mCellYTop,mCellYBottom;
130 int mSubCell; // subcell number of this item 129 int mSubCell; // subcell number of this item
131 int mSubCells; // Total number of subcells in cell of this item 130 int mSubCells; // Total number of subcells in cell of this item
132 int xPaintCoord; 131 int xPaintCoord;
133 int yPaintCoord; 132 int yPaintCoord;
134 int wPaintCoord; 133 int wPaintCoord;
135 int hPaintCoord; 134 int hPaintCoord;
136 // Variables to remember start position 135 // Variables to remember start position
137 int mStartCellX; 136 int mStartCellX;
138 int mStartCellXWidth; 137 int mStartCellXWidth;
139 int mStartCellYTop,mStartCellYBottom; 138 int mStartCellYTop,mStartCellYBottom;
140 int mLastMovePos; 139 int mLastMovePos;
141 140
142 // Multi item pointers 141 // Multi item pointers
143 KOAgendaItem *mFirstMultiItem; 142 KOAgendaItem *mFirstMultiItem;
144 KOAgendaItem *mNextMultiItem; 143 KOAgendaItem *mNextMultiItem;
145 KOAgendaItem *mLastMultiItem; 144 KOAgendaItem *mLastMultiItem;
146 145
147 int mFontPixelSize; 146 int mFontPixelSize;
148 Incidence *mIncidence; // corresponding event or todo 147 Incidence *mIncidence; // corresponding event or todo
149 QDate mDate; //date this events occurs (for recurrence) 148 QDate mDate; //date this events occurs (for recurrence)
150 //void showIcon( QLabel*, int ); 149 //void showIcon( QLabel*, int );
151 //QLabel *mTodoIconLabel; 150 //QLabel *mTodoIconLabel;
152 //QLabel *mItemLabel; 151 //QLabel *mItemLabel;
153 //QWidget *mIconBox; 152 //QWidget *mIconBox;
154 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 153 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
155 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 154 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
156 //QLabel *mIconMoreInfo; 155 //QLabel *mIconMoreInfo;
157 static QToolTipGroup *mToolTipGroup; 156 static QToolTipGroup *mToolTipGroup;
158 157
159 QColor mBackgroundColor; 158 QColor mBackgroundColor;
160 QColorGroup mColorGroup; 159 QColorGroup mColorGroup;
161 QString mDisplayedText; 160 QString mDisplayedText;
162 bool mSelected; 161 bool mSelected;
163 QPtrList<KOAgendaItem> mConflictItems; 162 QPtrList<KOAgendaItem> mConflictItems;
164}; 163};
165 164
166#endif // KOAGENDAITEM_H 165#endif // KOAGENDAITEM_H
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 5a63b35..f811fba 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -414,385 +414,385 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 477
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 479 this,SLOT(categoryChanged(Incidence *)));
480 480
481 481
482 mAgenda->setPopup( mAllAgendaPopup ); 482 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 483 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 484 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 485 mTimeLabels->setAgenda(mAgenda);
486 486
487 // Update widgets to reflect user preferences 487 // Update widgets to reflect user preferences
488 // updateConfig(); 488 // updateConfig();
489 489
490 // createDayLabels(); 490 // createDayLabels();
491 491
492 // these blank widgets make the All Day Event box line up with the agenda 492 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 496
497 // Scrolling 497 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 499 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 501 SLOT(setContentsPos(int)));
502 502
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 505
506 // Create/Show/Edit/Delete Event 506 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 507 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 508 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 510 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 512 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 514 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 516 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 518 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 520 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 525
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 527 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 529 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 531 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 533 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 535 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 537 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 538
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 540 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 542 SLOT(updateEventDates(KOAgendaItem *, int)));
543 543
544 // event indicator update 544 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 545 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 546 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 547 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 548 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 549 // drag signals
550 /* 550 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 551 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 552 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 554 SLOT(startDrag(Event *)));
555 */ 555 */
556 // synchronize selections 556 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 558 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 560 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 562 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 564 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 565 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 566 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 570 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 573
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576 576
577} 577}
578 578
579void KOAgendaView::toggleAllDay() 579void KOAgendaView::toggleAllDay()
580{ 580{
581 if ( mSplitterAgenda->firstHandle() ) 581 if ( mSplitterAgenda->firstHandle() )
582 mSplitterAgenda->firstHandle()->toggle(); 582 mSplitterAgenda->firstHandle()->toggle();
583} 583}
584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 584void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
585{ 585{
586 calendar()->addIncidence( inc ); 586 calendar()->addIncidence( inc );
587 587
588 if ( incOld ) { 588 if ( incOld ) {
589 if ( incOld->typeID() == todoID ) 589 if ( incOld->typeID() == todoID )
590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 590 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
591 else 591 else
592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 592 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
593 } 593 }
594 594
595} 595}
596void KOAgendaView::categoryChanged(Incidence * inc) 596void KOAgendaView::categoryChanged(Incidence * inc)
597{ 597{
598 mAgenda->categoryChanged( inc ); 598 mAgenda->categoryChanged( inc );
599 mAllDayAgenda->categoryChanged( inc ); 599 mAllDayAgenda->categoryChanged( inc );
600} 600}
601KOAgendaView::~KOAgendaView() 601KOAgendaView::~KOAgendaView()
602{ 602{
603 delete mAllAgendaPopup; 603 delete mAllAgendaPopup;
604 //delete mAllDayAgendaPopup; 604 //delete mAllDayAgendaPopup;
605 delete KOAgendaItem::paintPix(); 605 delete KOAgendaItem::paintPix();
606 delete KOAgendaItem::paintPixSel(); 606 delete KOAgendaItem::paintPixAllday();
607} 607}
608void KOAgendaView::resizeEvent( QResizeEvent* e ) 608void KOAgendaView::resizeEvent( QResizeEvent* e )
609{ 609{
610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 610 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
611 bool uc = false; 611 bool uc = false;
612 int ow = e->oldSize().width(); 612 int ow = e->oldSize().width();
613 int oh = e->oldSize().height(); 613 int oh = e->oldSize().height();
614 int w = e->size().width(); 614 int w = e->size().width();
615 int h = e->size().height(); 615 int h = e->size().height();
616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 616 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 617 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
618 uc = true; 618 uc = true;
619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 619 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
620 } 620 }
621 mUpcomingWidth = e->size().width() ; 621 mUpcomingWidth = e->size().width() ;
622 if ( mBlockUpdating || uc ) { 622 if ( mBlockUpdating || uc ) {
623 mBlockUpdating = false; 623 mBlockUpdating = false;
624 //mAgenda->setMinimumSize(800 , 600 ); 624 //mAgenda->setMinimumSize(800 , 600 );
625 //qDebug("mAgenda->resize+++++++++++++++ "); 625 //qDebug("mAgenda->resize+++++++++++++++ ");
626 updateConfig(); 626 updateConfig();
627 //qDebug("KOAgendaView::Updating now possible "); 627 //qDebug("KOAgendaView::Updating now possible ");
628 } else 628 } else
629 createDayLabels(); 629 createDayLabels();
630 //qDebug("resizeEvent end "); 630 //qDebug("resizeEvent end ");
631 631
632} 632}
633void KOAgendaView::slotDaylabelClicked( int num ) 633void KOAgendaView::slotDaylabelClicked( int num )
634{ 634{
635 635
636 QDate firstDate = mSelectedDates.first(); 636 QDate firstDate = mSelectedDates.first();
637 if ( num == -1 ) 637 if ( num == -1 )
638 emit showDateView( 6, firstDate ); 638 emit showDateView( 6, firstDate );
639 else if (num >= 0 ) { 639 else if (num >= 0 ) {
640 if ( mSelectedDates.count() == 1) 640 if ( mSelectedDates.count() == 1)
641 emit showDateView( 9, firstDate.addDays( num ) ); 641 emit showDateView( 9, firstDate.addDays( num ) );
642 else 642 else
643 emit showDateView( 3, firstDate.addDays( num ) ); 643 emit showDateView( 3, firstDate.addDays( num ) );
644 } 644 }
645 else 645 else
646 showDateView( 10, firstDate.addDays(1) ); 646 showDateView( 10, firstDate.addDays(1) );
647} 647}
648 648
649KOAgendaButton* KOAgendaView::getNewDaylabel() 649KOAgendaButton* KOAgendaView::getNewDaylabel()
650{ 650{
651 651
652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 652 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 653 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
654 mDayLabelsList.append( dayLabel ); 654 mDayLabelsList.append( dayLabel );
655 mLayoutDayLabels->addWidget(dayLabel); 655 mLayoutDayLabels->addWidget(dayLabel);
656 return dayLabel ; 656 return dayLabel ;
657} 657}
658 658
659void KOAgendaView::createDayLabels() 659void KOAgendaView::createDayLabels()
660{ 660{
661 661
662 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 662 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
663 // qDebug(" KOAgendaView::createDayLabels() blocked "); 663 // qDebug(" KOAgendaView::createDayLabels() blocked ");
664 return; 664 return;
665 665
666 } 666 }
667 int newHight; 667 int newHight;
668 if ( !mSelectedDates.count()) 668 if ( !mSelectedDates.count())
669 return; 669 return;
670 670
671 // ### Before deleting and recreating we could check if mSelectedDates changed... 671 // ### Before deleting and recreating we could check if mSelectedDates changed...
672 // It would remove some flickering and gain speed (since this is called by 672 // It would remove some flickering and gain speed (since this is called by
673 // each updateView() call) 673 // each updateView() call)
674 674
675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 675 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 676 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
677 if ( maxWid < 20 ) 677 if ( maxWid < 20 )
678 maxWid = 20; 678 maxWid = 20;
679 679
680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 680 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
681 QFontMetrics fm ( dlf ); 681 QFontMetrics fm ( dlf );
682 dlf.setBold( true ); 682 dlf.setBold( true );
683 int selCount = mSelectedDates.count(); 683 int selCount = mSelectedDates.count();
684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 684 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
685 QString dayTest = "Mon 20"; 685 QString dayTest = "Mon 20";
686 //QString dayTest = "Mon 20"; 686 //QString dayTest = "Mon 20";
687 int wid = fm.width( dayTest ); 687 int wid = fm.width( dayTest );
688 //maxWid -= ( selCount * 3 ); //working for QLabels 688 //maxWid -= ( selCount * 3 ); //working for QLabels
689 if ( QApplication::desktop()->width() <= 320 ) 689 if ( QApplication::desktop()->width() <= 320 )
690 maxWid -= ( selCount * 3 ); //working for QPushButton 690 maxWid -= ( selCount * 3 ); //working for QPushButton
691 else 691 else
692 maxWid -= ( selCount * 4 ); //working for QPushButton 692 maxWid -= ( selCount * 4 ); //working for QPushButton
693 if ( maxWid < 0 ) 693 if ( maxWid < 0 )
694 maxWid = 20; 694 maxWid = 20;
695 int needWid = wid * selCount; 695 int needWid = wid * selCount;
696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 696 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
697 //if ( needWid > maxWid ) 697 //if ( needWid > maxWid )
698 // qDebug("DAYLABELS TOOOOOOO BIG "); 698 // qDebug("DAYLABELS TOOOOOOO BIG ");
699 while ( needWid > maxWid ) { 699 while ( needWid > maxWid ) {
700 dayTest = dayTest.left( dayTest.length() - 1 ); 700 dayTest = dayTest.left( dayTest.length() - 1 );
701 wid = fm.width( dayTest ); 701 wid = fm.width( dayTest );
702 needWid = wid * selCount; 702 needWid = wid * selCount;
703 } 703 }
704 int maxLen = dayTest.length(); 704 int maxLen = dayTest.length();
705 int fontPoint = dlf.pointSize(); 705 int fontPoint = dlf.pointSize();
706 if ( maxLen < 2 ) { 706 if ( maxLen < 2 ) {
707 int fontPoint = dlf.pointSize(); 707 int fontPoint = dlf.pointSize();
708 while ( fontPoint > 4 ) { 708 while ( fontPoint > 4 ) {
709 --fontPoint; 709 --fontPoint;
710 dlf.setPointSize( fontPoint ); 710 dlf.setPointSize( fontPoint );
711 QFontMetrics f( dlf ); 711 QFontMetrics f( dlf );
712 wid = f.width( "30" ); 712 wid = f.width( "30" );
713 needWid = wid * selCount; 713 needWid = wid * selCount;
714 if ( needWid < maxWid ) 714 if ( needWid < maxWid )
715 break; 715 break;
716 } 716 }
717 maxLen = 2; 717 maxLen = 2;
718 } 718 }
719 //qDebug("Max len %d ", dayTest.length() ); 719 //qDebug("Max len %d ", dayTest.length() );
720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 720 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
721 dlf.setBold( false ); 721 dlf.setBold( false );
722 QFontMetrics tempF( dlf ); 722 QFontMetrics tempF( dlf );
723 newHight = tempF.height(); 723 newHight = tempF.height();
724 mDayLabels->setFont( dlf ); 724 mDayLabels->setFont( dlf );
725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 725 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
726 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 726 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
727 //mLayoutDayLabels->addSpacing( 2 ); 727 //mLayoutDayLabels->addSpacing( 2 );
728 // QFont lFont = dlf; 728 // QFont lFont = dlf;
729 bool appendLabels = false; 729 bool appendLabels = false;
730 KOAgendaButton *dayLabel; 730 KOAgendaButton *dayLabel;
731 dayLabel = mDayLabelsList.first(); 731 dayLabel = mDayLabelsList.first();
732 if ( !dayLabel ) { 732 if ( !dayLabel ) {
733 appendLabels = true; 733 appendLabels = true;
734 dayLabel = getNewDaylabel(); 734 dayLabel = getNewDaylabel();
735 } 735 }
736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 736 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
737 dayLabel->setFont( dlf ); 737 dayLabel->setFont( dlf );
738 dayLabel->setNum( -1 ); 738 dayLabel->setNum( -1 );
739 //dayLabel->setAlignment(QLabel::AlignHCenter); 739 //dayLabel->setAlignment(QLabel::AlignHCenter);
740 740
741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 741 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
742 dayLabel->show(); 742 dayLabel->show();
743 DateList::ConstIterator dit; 743 DateList::ConstIterator dit;
744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 744 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
745 int counter = -1; 745 int counter = -1;
746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 746 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
747 ++counter; 747 ++counter;
748 QDate date = *dit; 748 QDate date = *dit;
749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 749 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
750 if ( ! appendLabels ) { 750 if ( ! appendLabels ) {
751 dayLabel = mDayLabelsList.next(); 751 dayLabel = mDayLabelsList.next();
752 if ( !dayLabel ) 752 if ( !dayLabel )
753 appendLabels = true; 753 appendLabels = true;
754 } 754 }
755 if ( appendLabels ) { 755 if ( appendLabels ) {
756 dayLabel = getNewDaylabel(); 756 dayLabel = getNewDaylabel();
757 } 757 }
758 dayLabel->setMinimumWidth( 1 ); 758 dayLabel->setMinimumWidth( 1 );
759 dayLabel->setMaximumWidth( 10240 ); 759 dayLabel->setMaximumWidth( 10240 );
760 dayLabel->setFont( dlf ); 760 dayLabel->setFont( dlf );
761 dayLabel->show(); 761 dayLabel->show();
762 dayLabel->setAutoRepeat( false ); 762 dayLabel->setAutoRepeat( false );
763 dayLabel->setNum( counter ); 763 dayLabel->setNum( counter );
764 QString str; 764 QString str;
765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 765 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 766 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
767 switch ( maxLen ) { 767 switch ( maxLen ) {
768 case 2: 768 case 2:
769 str = QString::number( date.day() ); 769 str = QString::number( date.day() );
770 break; 770 break;
771 771
772 case 3: 772 case 3:
773 str = dayName.left( 1 ) +QString::number( date.day()); 773 str = dayName.left( 1 ) +QString::number( date.day());
774 774
775 break; 775 break;
776 case 4: 776 case 4:
777 str = dayName.left( 1 ) + " " +QString::number( date.day()); 777 str = dayName.left( 1 ) + " " +QString::number( date.day());
778 778
779 break; 779 break;
780 case 5: 780 case 5:
781 str = dayName.left( 2 ) + " " +QString::number( date.day()); 781 str = dayName.left( 2 ) + " " +QString::number( date.day());
782 782
783 break; 783 break;
784 case 6: 784 case 6:
785 str = dayName.left( 3 ) + " " +QString::number( date.day()); 785 str = dayName.left( 3 ) + " " +QString::number( date.day());
786 break; 786 break;
787 787
788 default: 788 default:
789 break; 789 break;
790 } 790 }
791 if ( oneday ) { 791 if ( oneday ) {
792 QString addString; 792 QString addString;
793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 793 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
794 addString = i18n("Today"); 794 addString = i18n("Today");
795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 795 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
796 addString = i18n("Tomorrow"); 796 addString = i18n("Tomorrow");
797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 797 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
798 addString = i18n("Yesterday"); 798 addString = i18n("Yesterday");