summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index db66413..8448a4c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -347,769 +347,769 @@ void EventIndicator::enableColumn(int column, bool enable)
347//////////////////////////////////////////////////////////////////////////// 347////////////////////////////////////////////////////////////////////////////
348//////////////////////////////////////////////////////////////////////////// 348////////////////////////////////////////////////////////////////////////////
349 349
350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
351 KOEventView (cal,parent,name) 351 KOEventView (cal,parent,name)
352{ 352{
353 mBlockUpdating = true; 353 mBlockUpdating = true;
354 mStartHour = 8; 354 mStartHour = 8;
355 mSelectedDates.append(QDate::currentDate()); 355 mSelectedDates.append(QDate::currentDate());
356 356
357 mLayoutDayLabels = 0; 357 mLayoutDayLabels = 0;
358 mDayLabelsFrame = 0; 358 mDayLabelsFrame = 0;
359 mDayLabels = 0; 359 mDayLabels = 0;
360 bool isRTL = KOGlobals::self()->reverseLayout(); 360 bool isRTL = KOGlobals::self()->reverseLayout();
361 361
362 if ( KOPrefs::instance()->mVerticalScreen ) { 362 if ( KOPrefs::instance()->mVerticalScreen ) {
363 mExpandedPixmap = SmallIcon( "1downarrow" ); 363 mExpandedPixmap = SmallIcon( "1downarrow" );
364 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 364 mNotExpandedPixmap = SmallIcon( "1uparrow" );
365 } else { 365 } else {
366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
368 } 368 }
369 369
370 QBoxLayout *topLayout = new QVBoxLayout(this); 370 QBoxLayout *topLayout = new QVBoxLayout(this);
371 371
372 // Create day name labels for agenda columns 372 // Create day name labels for agenda columns
373 mDayLabelsFrame = new QHBox(this); 373 mDayLabelsFrame = new QHBox(this);
374 topLayout->addWidget(mDayLabelsFrame); 374 topLayout->addWidget(mDayLabelsFrame);
375 mDayLabels = new QFrame (mDayLabelsFrame); 375 mDayLabels = new QFrame (mDayLabelsFrame);
376 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 376 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
377 // Create agenda splitter 377 // Create agenda splitter
378#ifndef KORG_NOSPLITTER 378#ifndef KORG_NOSPLITTER
379 mSplitterAgenda = new QSplitter(Vertical,this); 379 mSplitterAgenda = new QSplitter(Vertical,this);
380 topLayout->addWidget(mSplitterAgenda); 380 topLayout->addWidget(mSplitterAgenda);
381 mSplitterAgenda->setOpaqueResize(); 381 mSplitterAgenda->setOpaqueResize();
382 382
383 mAllDayFrame = new QHBox(mSplitterAgenda); 383 mAllDayFrame = new QHBox(mSplitterAgenda);
384 384
385 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 385 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
386#else 386#else
387#if 0 387#if 0
388 QWidget *mainBox = new QWidget( this ); 388 QWidget *mainBox = new QWidget( this );
389 topLayout->addWidget( mainBox ); 389 topLayout->addWidget( mainBox );
390 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 390 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
391 mAllDayFrame = new QHBox(mainBox); 391 mAllDayFrame = new QHBox(mainBox);
392 mainLayout->addWidget(mAllDayFrame); 392 mainLayout->addWidget(mAllDayFrame);
393 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 393 mainLayout->setStretchFactor( mAllDayFrame, 0 );
394 mAllDayFrame->setFocusPolicy(NoFocus); 394 mAllDayFrame->setFocusPolicy(NoFocus);
395 QWidget *agendaFrame = new QWidget(mainBox); 395 QWidget *agendaFrame = new QWidget(mainBox);
396 mainLayout->addWidget(agendaFrame); 396 mainLayout->addWidget(agendaFrame);
397 mainLayout->setStretchFactor( agendaFrame, 10 ); 397 mainLayout->setStretchFactor( agendaFrame, 10 );
398 398
399 agendaFrame->setFocusPolicy(NoFocus); 399 agendaFrame->setFocusPolicy(NoFocus);
400#endif 400#endif
401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
403 topLayout->addWidget( mSplitterAgenda ); 403 topLayout->addWidget( mSplitterAgenda );
404 mAllDayFrame = new QHBox(mSplitterAgenda); 404 mAllDayFrame = new QHBox(mSplitterAgenda);
405 mAllDayFrame->setFocusPolicy(NoFocus); 405 mAllDayFrame->setFocusPolicy(NoFocus);
406 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 406 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
407 agendaFrame->setFocusPolicy(NoFocus); 407 agendaFrame->setFocusPolicy(NoFocus);
408 408
409#endif 409#endif
410 410
411 // Create all-day agenda widget 411 // Create all-day agenda widget
412 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 412 mDummyAllDayLeft = new QVBox( mAllDayFrame );
413 413
414 mExpandButton = new QPushButton(mDummyAllDayLeft); 414 mExpandButton = new QPushButton(mDummyAllDayLeft);
415 mExpandButton->setPixmap( mNotExpandedPixmap ); 415 mExpandButton->setPixmap( mNotExpandedPixmap );
416 int widebut = mExpandButton->sizeHint().width(); 416 int widebut = mExpandButton->sizeHint().width();
417 if ( QApplication::desktop()->width() < 480 ) 417 if ( QApplication::desktop()->width() < 480 )
418 widebut = widebut*2; 418 widebut = widebut*2;
419 else 419 else
420 widebut = (widebut*3) / 2; 420 widebut = (widebut*3) / 2;
421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 421 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
422 // QSizePolicy::Fixed ) ); 422 // QSizePolicy::Fixed ) );
423 mExpandButton->setFixedSize( widebut, widebut); 423 mExpandButton->setFixedSize( widebut, widebut);
424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 424 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
425 mExpandButton->setFocusPolicy(NoFocus); 425 mExpandButton->setFocusPolicy(NoFocus);
426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 426 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
427 mAllDayAgenda->setFocusPolicy(NoFocus); 427 mAllDayAgenda->setFocusPolicy(NoFocus);
428 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 428 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
429 429
430 // Create event context menu for all day agenda 430 // Create event context menu for all day agenda
431 mAllDayAgendaPopup = eventPopup(); 431 mAllDayAgendaPopup = eventPopup();
432 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 432 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
433 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 433 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
434 434
435 // Create agenda frame 435 // Create agenda frame
436 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 436 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
437 // QHBox *agendaFrame = new QHBox(splitterAgenda); 437 // QHBox *agendaFrame = new QHBox(splitterAgenda);
438 438
439 // create event indicator bars 439 // create event indicator bars
440 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 440 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
441 agendaLayout->addWidget(mEventIndicatorTop,0,1); 441 agendaLayout->addWidget(mEventIndicatorTop,0,1);
442 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 442 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
443 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 443 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
444 agendaFrame); 444 agendaFrame);
445 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 445 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
446 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 446 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
447 agendaLayout->addWidget(dummyAgendaRight,0,2); 447 agendaLayout->addWidget(dummyAgendaRight,0,2);
448 448
449 // Create time labels 449 // Create time labels
450 mTimeLabels = new TimeLabels(24,agendaFrame); 450 mTimeLabels = new TimeLabels(24,agendaFrame);
451 agendaLayout->addWidget(mTimeLabels,1,0); 451 agendaLayout->addWidget(mTimeLabels,1,0);
452 connect(mTimeLabels,SIGNAL( scaleChanged()), 452 connect(mTimeLabels,SIGNAL( scaleChanged()),
453 this,SLOT(updateConfig())); 453 this,SLOT(updateConfig()));
454 454
455 // Create agenda 455 // Create agenda
456 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 456 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
457 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 457 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
458 agendaLayout->setColStretch(1,1); 458 agendaLayout->setColStretch(1,1);
459 mAgenda->setFocusPolicy(NoFocus); 459 mAgenda->setFocusPolicy(NoFocus);
460 // Create event context menu for agenda 460 // Create event context menu for agenda
461 mAgendaPopup = eventPopup(); 461 mAgendaPopup = eventPopup();
462 462
463 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 463 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
464 i18n("Toggle Alarm"),mAgenda, 464 i18n("Toggle Alarm"),mAgenda,
465 SLOT(popupAlarm()),true); 465 SLOT(popupAlarm()),true);
466 466
467 467
468 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 468 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
469 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 469 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
470 470
471 // make connections between dependent widgets 471 // make connections between dependent widgets
472 mTimeLabels->setAgenda(mAgenda); 472 mTimeLabels->setAgenda(mAgenda);
473 473
474 // Update widgets to reflect user preferences 474 // Update widgets to reflect user preferences
475 // updateConfig(); 475 // updateConfig();
476 476
477 // createDayLabels(); 477 // createDayLabels();
478 478
479 // these blank widgets make the All Day Event box line up with the agenda 479 // these blank widgets make the All Day Event box line up with the agenda
480 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 480 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
481 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 481 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
482 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 482 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
483 483
484 // Scrolling 484 // Scrolling
485 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 mTimeLabels, SLOT(positionChanged())); 486 mTimeLabels, SLOT(positionChanged()));
487 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 487 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
488 SLOT(setContentsPos(int))); 488 SLOT(setContentsPos(int)));
489 489
490 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 490 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
491 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 491 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
492 492
493 // Create/Show/Edit/Delete Event 493 // Create/Show/Edit/Delete Event
494 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 494 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
495 SLOT(newEvent(int,int))); 495 SLOT(newEvent(int,int)));
496 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 496 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
497 SLOT(newTodo(int,int))); 497 SLOT(newTodo(int,int)));
498 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 498 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
499 SLOT(newEvent(int,int,int,int))); 499 SLOT(newEvent(int,int,int,int)));
500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
501 SLOT(newEventAllDay(int,int))); 501 SLOT(newEventAllDay(int,int)));
502 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 502 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
503 SLOT(newTodoAllDay(int,int))); 503 SLOT(newTodoAllDay(int,int)));
504 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 504 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
505 SLOT(newEventAllDay(int,int))); 505 SLOT(newEventAllDay(int,int)));
506 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
507 SLOT(newTimeSpanSelected(int,int,int,int))); 507 SLOT(newTimeSpanSelected(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 508 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
509 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 509 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
510 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 510 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
511 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 511 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
512 512
513 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 513 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
514 SIGNAL(editIncidenceSignal(Incidence *))); 514 SIGNAL(editIncidenceSignal(Incidence *)));
515 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 515 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
516 SIGNAL(editIncidenceSignal(Incidence *))); 516 SIGNAL(editIncidenceSignal(Incidence *)));
517 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 517 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
518 SIGNAL(showIncidenceSignal(Incidence *))); 518 SIGNAL(showIncidenceSignal(Incidence *)));
519 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 519 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
520 SIGNAL(showIncidenceSignal(Incidence *))); 520 SIGNAL(showIncidenceSignal(Incidence *)));
521 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
522 SIGNAL(deleteIncidenceSignal(Incidence *))); 522 SIGNAL(deleteIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
524 SIGNAL(deleteIncidenceSignal(Incidence *))); 524 SIGNAL(deleteIncidenceSignal(Incidence *)));
525 525
526 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 526 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
527 SLOT(updateEventDates(KOAgendaItem *, int ))); 527 SLOT(updateEventDates(KOAgendaItem *, int )));
528 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 528 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
529 SLOT(updateEventDates(KOAgendaItem *, int))); 529 SLOT(updateEventDates(KOAgendaItem *, int)));
530 530
531 // event indicator update 531 // event indicator update
532 connect(mAgenda,SIGNAL(lowerYChanged(int)), 532 connect(mAgenda,SIGNAL(lowerYChanged(int)),
533 SLOT(updateEventIndicatorTop(int))); 533 SLOT(updateEventIndicatorTop(int)));
534 connect(mAgenda,SIGNAL(upperYChanged(int)), 534 connect(mAgenda,SIGNAL(upperYChanged(int)),
535 SLOT(updateEventIndicatorBottom(int))); 535 SLOT(updateEventIndicatorBottom(int)));
536 // drag signals 536 // drag signals
537 /* 537 /*
538 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 538 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
539 SLOT(startDrag(Event *))); 539 SLOT(startDrag(Event *)));
540 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 540 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
541 SLOT(startDrag(Event *))); 541 SLOT(startDrag(Event *)));
542 */ 542 */
543 // synchronize selections 543 // synchronize selections
544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
545 mAllDayAgenda, SLOT( deselectItem() ) ); 545 mAllDayAgenda, SLOT( deselectItem() ) );
546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
547 mAgenda, SLOT( deselectItem() ) ); 547 mAgenda, SLOT( deselectItem() ) );
548 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 548 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
549 SIGNAL( incidenceSelected( Incidence * ) ) ); 549 SIGNAL( incidenceSelected( Incidence * ) ) );
550 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 550 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
551 SIGNAL( incidenceSelected( Incidence * ) ) ); 551 SIGNAL( incidenceSelected( Incidence * ) ) );
552 connect( mAgenda, SIGNAL( resizedSignal() ), 552 connect( mAgenda, SIGNAL( resizedSignal() ),
553 SLOT( updateConfig( ) ) ); 553 SLOT( updateConfig( ) ) );
554 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 554 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
555 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 555 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
556 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 556 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
557 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 557 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
558 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 558 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
559 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 559 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
560 560
561 561
562} 562}
563 563
564void KOAgendaView::toggleAllDay() 564void KOAgendaView::toggleAllDay()
565{ 565{
566 if ( mSplitterAgenda->firstHandle() ) 566 if ( mSplitterAgenda->firstHandle() )
567 mSplitterAgenda->firstHandle()->toggle(); 567 mSplitterAgenda->firstHandle()->toggle();
568} 568}
569void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 569void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
570{ 570{
571 calendar()->addIncidence( inc ); 571 calendar()->addIncidence( inc );
572 572
573 if ( incOld ) { 573 if ( incOld ) {
574 if ( incOld->type() == "Todo" ) 574 if ( incOld->type() == "Todo" )
575 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 575 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
576 else 576 else
577 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 577 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
578 } 578 }
579 579
580} 580}
581 581
582KOAgendaView::~KOAgendaView() 582KOAgendaView::~KOAgendaView()
583{ 583{
584 delete mAgendaPopup; 584 delete mAgendaPopup;
585 delete mAllDayAgendaPopup; 585 delete mAllDayAgendaPopup;
586 delete KOAgendaItem::paintPix(); 586 delete KOAgendaItem::paintPix();
587 delete KOAgendaItem::paintPixSel(); 587 delete KOAgendaItem::paintPixSel();
588} 588}
589void KOAgendaView::resizeEvent( QResizeEvent* e ) 589void KOAgendaView::resizeEvent( QResizeEvent* e )
590{ 590{
591 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 591 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
592 bool uc = false; 592 bool uc = false;
593 int ow = e->oldSize().width(); 593 int ow = e->oldSize().width();
594 int oh = e->oldSize().height(); 594 int oh = e->oldSize().height();
595 int w = e->size().width(); 595 int w = e->size().width();
596 int h = e->size().height(); 596 int h = e->size().height();
597 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 597 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
598 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 598 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
599 uc = true; 599 uc = true;
600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
601 } 601 }
602 mUpcomingWidth = e->size().width() ; 602 mUpcomingWidth = e->size().width() ;
603 if ( mBlockUpdating || uc ) { 603 if ( mBlockUpdating || uc ) {
604 mBlockUpdating = false; 604 mBlockUpdating = false;
605 //mAgenda->setMinimumSize(800 , 600 ); 605 //mAgenda->setMinimumSize(800 , 600 );
606 //qDebug("mAgenda->resize+++++++++++++++ "); 606 //qDebug("mAgenda->resize+++++++++++++++ ");
607 updateConfig(); 607 updateConfig();
608 //qDebug("KOAgendaView::Updating now possible "); 608 //qDebug("KOAgendaView::Updating now possible ");
609 } else 609 } else
610 createDayLabels(); 610 createDayLabels();
611 //qDebug("resizeEvent end "); 611 //qDebug("resizeEvent end ");
612 612
613} 613}
614void KOAgendaView::slotDaylabelClicked( int num ) 614void KOAgendaView::slotDaylabelClicked( int num )
615{ 615{
616 616
617 QDate firstDate = mSelectedDates.first(); 617 QDate firstDate = mSelectedDates.first();
618 if ( num == -1 ) 618 if ( num == -1 )
619 emit showDateView( 6, firstDate ); 619 emit showDateView( 6, firstDate );
620 else if (num >= 0 ) { 620 else if (num >= 0 ) {
621 if ( mSelectedDates.count() == 1) 621 if ( mSelectedDates.count() == 1)
622 emit showDateView( 9, firstDate.addDays( num ) ); 622 emit showDateView( 9, firstDate.addDays( num ) );
623 else 623 else
624 emit showDateView( 3, firstDate.addDays( num ) ); 624 emit showDateView( 3, firstDate.addDays( num ) );
625 } 625 }
626 else 626 else
627 showDateView( 10, firstDate.addDays(1) ); 627 showDateView( 10, firstDate.addDays(1) );
628} 628}
629 629
630KOAgendaButton* KOAgendaView::getNewDaylabel() 630KOAgendaButton* KOAgendaView::getNewDaylabel()
631{ 631{
632 632
633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
635 mDayLabelsList.append( dayLabel ); 635 mDayLabelsList.append( dayLabel );
636 mLayoutDayLabels->addWidget(dayLabel); 636 mLayoutDayLabels->addWidget(dayLabel);
637 return dayLabel ; 637 return dayLabel ;
638} 638}
639 639
640void KOAgendaView::createDayLabels() 640void KOAgendaView::createDayLabels()
641{ 641{
642 642
643 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 643 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
644 // qDebug(" KOAgendaView::createDayLabels() blocked "); 644 // qDebug(" KOAgendaView::createDayLabels() blocked ");
645 return; 645 return;
646 646
647 } 647 }
648 int newHight; 648 int newHight;
649 649
650 // ### Before deleting and recreating we could check if mSelectedDates changed... 650 // ### Before deleting and recreating we could check if mSelectedDates changed...
651 // It would remove some flickering and gain speed (since this is called by 651 // It would remove some flickering and gain speed (since this is called by
652 // each updateView() call) 652 // each updateView() call)
653 653
654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
656 if ( maxWid < 0 ) 656 if ( maxWid < 0 )
657 maxWid = 20; 657 maxWid = 20;
658 658
659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
660 QFontMetrics fm ( dlf ); 660 QFontMetrics fm ( dlf );
661 int selCount = mSelectedDates.count(); 661 int selCount = mSelectedDates.count();
662 QString dayTest = "Mon 20"; 662 QString dayTest = "Mon 20";
663 //QString dayTest = "Mon 20"; 663 //QString dayTest = "Mon 20";
664 int wid = fm.width( dayTest ); 664 int wid = fm.width( dayTest );
665 //maxWid -= ( selCount * 3 ); //working for QLabels 665 //maxWid -= ( selCount * 3 ); //working for QLabels
666 maxWid -= ( selCount * 3 ); //working for QPushButton 666 maxWid -= ( selCount * 3 ); //working for QPushButton
667 if ( maxWid < 0 ) 667 if ( maxWid < 0 )
668 maxWid = 20; 668 maxWid = 20;
669 int needWid = wid * selCount; 669 int needWid = wid * selCount;
670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
671 //if ( needWid > maxWid ) 671 //if ( needWid > maxWid )
672 // qDebug("DAYLABELS TOOOOOOO BIG "); 672 // qDebug("DAYLABELS TOOOOOOO BIG ");
673 while ( needWid > maxWid ) { 673 while ( needWid > maxWid ) {
674 dayTest = dayTest.left( dayTest.length() - 1 ); 674 dayTest = dayTest.left( dayTest.length() - 1 );
675 wid = fm.width( dayTest ); 675 wid = fm.width( dayTest );
676 needWid = wid * selCount; 676 needWid = wid * selCount;
677 } 677 }
678 int maxLen = dayTest.length(); 678 int maxLen = dayTest.length();
679 int fontPoint = dlf.pointSize(); 679 int fontPoint = dlf.pointSize();
680 if ( maxLen < 2 ) { 680 if ( maxLen < 2 ) {
681 int fontPoint = dlf.pointSize(); 681 int fontPoint = dlf.pointSize();
682 while ( fontPoint > 4 ) { 682 while ( fontPoint > 4 ) {
683 --fontPoint; 683 --fontPoint;
684 dlf.setPointSize( fontPoint ); 684 dlf.setPointSize( fontPoint );
685 QFontMetrics f( dlf ); 685 QFontMetrics f( dlf );
686 wid = f.width( "30" ); 686 wid = f.width( "30" );
687 needWid = wid * selCount; 687 needWid = wid * selCount;
688 if ( needWid < maxWid ) 688 if ( needWid < maxWid )
689 break; 689 break;
690 } 690 }
691 maxLen = 2; 691 maxLen = 2;
692 } 692 }
693 //qDebug("Max len %d ", dayTest.length() ); 693 //qDebug("Max len %d ", dayTest.length() );
694 694
695 QFontMetrics tempF( dlf ); 695 QFontMetrics tempF( dlf );
696 newHight = tempF.height(); 696 newHight = tempF.height();
697 mDayLabels->setFont( dlf ); 697 mDayLabels->setFont( dlf );
698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
699 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 699 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
700 //mLayoutDayLabels->addSpacing( 2 ); 700 //mLayoutDayLabels->addSpacing( 2 );
701 // QFont lFont = dlf; 701 // QFont lFont = dlf;
702 bool appendLabels = false; 702 bool appendLabels = false;
703 KOAgendaButton *dayLabel; 703 KOAgendaButton *dayLabel;
704 dayLabel = mDayLabelsList.first(); 704 dayLabel = mDayLabelsList.first();
705 if ( !dayLabel ) { 705 if ( !dayLabel ) {
706 appendLabels = true; 706 appendLabels = true;
707 dayLabel = getNewDaylabel(); 707 dayLabel = getNewDaylabel();
708 } 708 }
709 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 709 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
710 dayLabel->setFont( dlf ); 710 dayLabel->setFont( dlf );
711 dayLabel->setNum( -1 ); 711 dayLabel->setNum( -1 );
712 //dayLabel->setAlignment(QLabel::AlignHCenter); 712 //dayLabel->setAlignment(QLabel::AlignHCenter);
713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
714 dayLabel->show(); 714 dayLabel->show();
715 DateList::ConstIterator dit; 715 DateList::ConstIterator dit;
716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
717 int counter = -1; 717 int counter = -1;
718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
719 ++counter; 719 ++counter;
720 QDate date = *dit; 720 QDate date = *dit;
721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
722 if ( ! appendLabels ) { 722 if ( ! appendLabels ) {
723 dayLabel = mDayLabelsList.next(); 723 dayLabel = mDayLabelsList.next();
724 if ( !dayLabel ) 724 if ( !dayLabel )
725 appendLabels = true; 725 appendLabels = true;
726 } 726 }
727 if ( appendLabels ) { 727 if ( appendLabels ) {
728 dayLabel = getNewDaylabel(); 728 dayLabel = getNewDaylabel();
729 } 729 }
730 dayLabel->setMinimumWidth( 1 ); 730 dayLabel->setMinimumWidth( 1 );
731 dayLabel->setMaximumWidth( 1024 ); 731 dayLabel->setMaximumWidth( 10240 );
732 dayLabel->setFont( dlf ); 732 dayLabel->setFont( dlf );
733 dayLabel->show(); 733 dayLabel->show();
734 dayLabel->setNum( counter ); 734 dayLabel->setNum( counter );
735 QString str; 735 QString str;
736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
738 switch ( maxLen ) { 738 switch ( maxLen ) {
739 case 2: 739 case 2:
740 str = QString::number( date.day() ); 740 str = QString::number( date.day() );
741 break; 741 break;
742 742
743 case 3: 743 case 3:
744 str = dayName.left( 1 ) +QString::number( date.day()); 744 str = dayName.left( 1 ) +QString::number( date.day());
745 745
746 break; 746 break;
747 case 4: 747 case 4:
748 str = dayName.left( 1 ) + " " +QString::number( date.day()); 748 str = dayName.left( 1 ) + " " +QString::number( date.day());
749 749
750 break; 750 break;
751 case 5: 751 case 5:
752 str = dayName.left( 2 ) + " " +QString::number( date.day()); 752 str = dayName.left( 2 ) + " " +QString::number( date.day());
753 753
754 break; 754 break;
755 case 6: 755 case 6:
756 str = dayName.left( 3 ) + " " +QString::number( date.day()); 756 str = dayName.left( 3 ) + " " +QString::number( date.day());
757 break; 757 break;
758 758
759 default: 759 default:
760 break; 760 break;
761 } 761 }
762 if ( oneday ) { 762 if ( oneday ) {
763 QString addString; 763 QString addString;
764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
765 addString = i18n("Today"); 765 addString = i18n("Today");
766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
767 addString = i18n("Tomorrow"); 767 addString = i18n("Tomorrow");
768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
769 addString = i18n("Yesterday"); 769 addString = i18n("Yesterday");
770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
771 addString = i18n("Day before yesterday"); 771 addString = i18n("Day before yesterday");
772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
773 addString = i18n("Day after tomorrow"); 773 addString = i18n("Day after tomorrow");
774 if ( !addString.isEmpty() ) { 774 if ( !addString.isEmpty() ) {
775 str = addString+", " + str; 775 str = addString+", " + str;
776 } 776 }
777 } 777 }
778 dayLabel->setText(str); 778 dayLabel->setText(str);
779 //dayLabel->setAlignment(QLabel::AlignHCenter); 779 //dayLabel->setAlignment(QLabel::AlignHCenter);
780 if (date == QDate::currentDate()) { 780 if (date == QDate::currentDate()) {
781 QFont bFont = dlf; 781 QFont bFont = dlf;
782 bFont.setBold( true ); 782 bFont.setBold( true );
783 dayLabel->setFont(bFont); 783 dayLabel->setFont(bFont);
784 } 784 }
785 //dayLayout->addWidget(dayLabel); 785 //dayLayout->addWidget(dayLabel);
786 786
787#ifndef KORG_NOPLUGINS 787#ifndef KORG_NOPLUGINS
788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
789 CalendarDecoration *it; 789 CalendarDecoration *it;
790 for(it = cds.first(); it; it = cds.next()) { 790 for(it = cds.first(); it; it = cds.next()) {
791 QString text = it->shortText( date ); 791 QString text = it->shortText( date );
792 if ( !text.isEmpty() ) { 792 if ( !text.isEmpty() ) {
793 QLabel *label = new QLabel(text,mDayLabels); 793 QLabel *label = new QLabel(text,mDayLabels);
794 label->setAlignment(AlignCenter); 794 label->setAlignment(AlignCenter);
795 dayLayout->addWidget(label); 795 dayLayout->addWidget(label);
796 } 796 }
797 } 797 }
798 798
799 for(it = cds.first(); it; it = cds.next()) { 799 for(it = cds.first(); it; it = cds.next()) {
800 QWidget *wid = it->smallWidget(mDayLabels,date); 800 QWidget *wid = it->smallWidget(mDayLabels,date);
801 if ( wid ) { 801 if ( wid ) {
802 // wid->setHeight(20); 802 // wid->setHeight(20);
803 dayLayout->addWidget(wid); 803 dayLayout->addWidget(wid);
804 } 804 }
805 } 805 }
806#endif 806#endif
807 } 807 }
808 if ( ! appendLabels ) { 808 if ( ! appendLabels ) {
809 dayLabel = mDayLabelsList.next(); 809 dayLabel = mDayLabelsList.next();
810 if ( !dayLabel ) 810 if ( !dayLabel )
811 appendLabels = true; 811 appendLabels = true;
812 } 812 }
813 if ( appendLabels ) { 813 if ( appendLabels ) {
814 dayLabel = getNewDaylabel(); 814 dayLabel = getNewDaylabel();
815 } 815 }
816 //dayLabel->hide();//test only 816 //dayLabel->hide();//test only
817 817
818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
819 if ( offset < 0 ) offset = 0; 819 if ( offset < 0 ) offset = 0;
820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
822 dayLabel->setFont( dlf ); 822 dayLabel->setFont( dlf );
823 dayLabel->show(); 823 dayLabel->show();
824 dayLabel->setNum( -2 ); 824 dayLabel->setNum( -2 );
825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
828 if ( !appendLabels ) { 828 if ( !appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 while ( dayLabel ) { 830 while ( dayLabel ) {
831 //qDebug("!dayLabel %d",dayLabel ); 831 //qDebug("!dayLabel %d",dayLabel );
832 dayLabel->hide(); 832 dayLabel->hide();
833 dayLabel = mDayLabelsList.next(); 833 dayLabel = mDayLabelsList.next();
834 } 834 }
835 } 835 }
836 //mDayLabelsFrame->show(); 836 //mDayLabelsFrame->show();
837 //mDayLabels->show(); 837 //mDayLabels->show();
838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
840 mDayLabelsFrame->setFixedHeight( newHight ); 840 mDayLabelsFrame->setFixedHeight( newHight );
841} 841}
842 842
843int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
844{ 844{
845 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
846 return 0; 846 return 0;
847} 847}
848 848
849int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
850{ 850{
851 return mSelectedDates.count(); 851 return mSelectedDates.count();
852} 852}
853 853
854QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
855{ 855{
856 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
857 Incidence *incidence; 857 Incidence *incidence;
858 858
859 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
860 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
861 861
862 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
863 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
864 864
865 return selected; 865 return selected;
866} 866}
867 867
868DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
869{ 869{
870 DateList selected; 870 DateList selected;
871 QDate qd; 871 QDate qd;
872 872
873 qd = mAgenda->selectedIncidenceDate(); 873 qd = mAgenda->selectedIncidenceDate();
874 if (qd.isValid()) selected.append(qd); 874 if (qd.isValid()) selected.append(qd);
875 875
876 qd = mAllDayAgenda->selectedIncidenceDate(); 876 qd = mAllDayAgenda->selectedIncidenceDate();
877 if (qd.isValid()) selected.append(qd); 877 if (qd.isValid()) selected.append(qd);
878 878
879 return selected; 879 return selected;
880} 880}
881 881
882 882
883void KOAgendaView::updateView() 883void KOAgendaView::updateView()
884{ 884{
885 if ( mBlockUpdating ) 885 if ( mBlockUpdating )
886 return; 886 return;
887 // kdDebug() << "KOAgendaView::updateView()" << endl; 887 // kdDebug() << "KOAgendaView::updateView()" << endl;
888 fillAgenda(); 888 fillAgenda();
889 889
890} 890}
891 891
892 892
893/* 893/*
894 Update configuration settings for the agenda view. This method is not 894 Update configuration settings for the agenda view. This method is not
895 complete. 895 complete.
896*/ 896*/
897void KOAgendaView::updateConfig() 897void KOAgendaView::updateConfig()
898{ 898{
899 if ( mBlockUpdating ) 899 if ( mBlockUpdating )
900 return; 900 return;
901 901
902 902
903 903
904 // update config for children 904 // update config for children
905 mTimeLabels->updateConfig(); 905 mTimeLabels->updateConfig();
906 mAgenda->storePosition(); 906 mAgenda->storePosition();
907 mAgenda->updateConfig(); 907 mAgenda->updateConfig();
908 mAllDayAgenda->updateConfig(); 908 mAllDayAgenda->updateConfig();
909 // widget synchronization 909 // widget synchronization
910 //TODO: find a better way, maybe signal/slot 910 //TODO: find a better way, maybe signal/slot
911 mTimeLabels->positionChanged(); 911 mTimeLabels->positionChanged();
912 912
913 // for some reason, this needs to be called explicitly 913 // for some reason, this needs to be called explicitly
914 mTimeLabels->repaint(); 914 mTimeLabels->repaint();
915 915
916 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 916 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
917 917
918 // ToolTips displaying summary of events 918 // ToolTips displaying summary of events
919 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 919 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
920 ->mEnableToolTips); 920 ->mEnableToolTips);
921 921
922 //setHolidayMasks(); 922 //setHolidayMasks();
923 923
924 //createDayLabels(); called by via updateView(); 924 //createDayLabels(); called by via updateView();
925 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 925 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
926 updateView(); 926 updateView();
927 mAgenda->restorePosition(); 927 mAgenda->restorePosition();
928} 928}
929 929
930 930
931void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 931void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
932{ 932{
933 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 933 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
934 //qDebug("KOAgendaView::updateEventDates "); 934 //qDebug("KOAgendaView::updateEventDates ");
935 QDateTime startDt,endDt; 935 QDateTime startDt,endDt;
936 QDate startDate; 936 QDate startDate;
937 int lenInSecs; 937 int lenInSecs;
938 // if ( type == KOAgenda::RESIZETOP ) 938 // if ( type == KOAgenda::RESIZETOP )
939 // qDebug("RESIZETOP "); 939 // qDebug("RESIZETOP ");
940 // if ( type == KOAgenda::RESIZEBOTTOM ) 940 // if ( type == KOAgenda::RESIZEBOTTOM )
941 // qDebug("RESIZEBOTTOM "); 941 // qDebug("RESIZEBOTTOM ");
942 // if ( type == KOAgenda::MOVE ) 942 // if ( type == KOAgenda::MOVE )
943 // qDebug("MOVE "); 943 // qDebug("MOVE ");
944 if ( item->incidence()->type() == "Event" ) { 944 if ( item->incidence()->type() == "Event" ) {
945 startDt =item->incidence()->dtStart(); 945 startDt =item->incidence()->dtStart();
946 endDt = item->incidence()->dtEnd(); 946 endDt = item->incidence()->dtEnd();
947 lenInSecs = startDt.secsTo( endDt ); 947 lenInSecs = startDt.secsTo( endDt );
948 } 948 }
949 949
950 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 950 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
951 951
952 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 952 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
953 startDate = mSelectedDates[item->mLastMoveXPos]; 953 startDate = mSelectedDates[item->mLastMoveXPos];
954 } else { 954 } else {
955 if (item->cellX() < 0) { 955 if (item->cellX() < 0) {
956 startDate = (mSelectedDates.first()).addDays(item->cellX()); 956 startDate = (mSelectedDates.first()).addDays(item->cellX());
957 } else { 957 } else {
958 startDate = mSelectedDates[item->cellX()]; 958 startDate = mSelectedDates[item->cellX()];
959 } 959 }
960 } 960 }
961 startDt.setDate(startDate); 961 startDt.setDate(startDate);
962 962
963 if (item->incidence()->doesFloat()) { 963 if (item->incidence()->doesFloat()) {
964 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 964 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
965 } else { 965 } else {
966 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 966 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
967 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 967 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
968 if ( item->incidence()->type() == "Event" ) { 968 if ( item->incidence()->type() == "Event" ) {
969 if ( type == KOAgenda::MOVE ) { 969 if ( type == KOAgenda::MOVE ) {
970 endDt = startDt.addSecs(lenInSecs); 970 endDt = startDt.addSecs(lenInSecs);
971 971
972 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 972 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
973 if (item->lastMultiItem()) { 973 if (item->lastMultiItem()) {
974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
975 endDt.setDate(startDate. 975 endDt.setDate(startDate.
976 addDays(item->lastMultiItem()->cellX() - item->cellX())); 976 addDays(item->lastMultiItem()->cellX() - item->cellX()));
977 } else { 977 } else {
978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
979 endDt.setDate(startDate); 979 endDt.setDate(startDate);
980 } 980 }
981 } 981 }
982 } else { 982 } else {
983 // todo 983 // todo
984 if (item->lastMultiItem()) { 984 if (item->lastMultiItem()) {
985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
986 endDt.setDate(startDate. 986 endDt.setDate(startDate.
987 addDays(item->lastMultiItem()->cellX() - item->cellX())); 987 addDays(item->lastMultiItem()->cellX() - item->cellX()));
988 } else { 988 } else {
989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
990 if ( item->cellYBottom() > 0 ) 990 if ( item->cellYBottom() > 0 )
991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
992 else 992 else
993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
994 endDt.setDate(startDate); 994 endDt.setDate(startDate);
995 } 995 }
996 } 996 }
997 } 997 }
998 if ( item->incidence()->type() == "Event" ) { 998 if ( item->incidence()->type() == "Event" ) {
999 item->incidence()->setDtStart(startDt); 999 item->incidence()->setDtStart(startDt);
1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1001 } else if ( item->incidence()->type() == "Todo" ) { 1001 } else if ( item->incidence()->type() == "Todo" ) {
1002 Todo* to = static_cast<Todo*>(item->incidence()); 1002 Todo* to = static_cast<Todo*>(item->incidence());
1003 1003
1004 to->setDtDue(endDt); 1004 to->setDtDue(endDt);
1005 if ( to->hasStartDate() ) { 1005 if ( to->hasStartDate() ) {
1006 if (to->dtStart() >= to->dtDue() ) 1006 if (to->dtStart() >= to->dtDue() )
1007 to->setDtStart(to->dtDue().addDays( -2 )); 1007 to->setDtStart(to->dtDue().addDays( -2 ));
1008 } 1008 }
1009 1009
1010 } 1010 }
1011 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1011 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1012 item->incidence()->setRevision(item->incidence()->revision()+1); 1012 item->incidence()->setRevision(item->incidence()->revision()+1);
1013 item->setItemDate(startDt.date()); 1013 item->setItemDate(startDt.date());
1014 //item->updateItem(); 1014 //item->updateItem();
1015 if ( item->incidence()->type() == "Todo" ) { 1015 if ( item->incidence()->type() == "Todo" ) {
1016 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1016 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1017 1017
1018 } 1018 }
1019 else 1019 else
1020 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1020 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1021 item->updateItem(); 1021 item->updateItem();
1022} 1022}
1023 1023
1024void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1024void KOAgendaView::showDates( const QDate &start, const QDate &end )
1025{ 1025{
1026 // kdDebug() << "KOAgendaView::selectDates" << endl; 1026 // kdDebug() << "KOAgendaView::selectDates" << endl;
1027 1027
1028 mSelectedDates.clear(); 1028 mSelectedDates.clear();
1029 // qDebug("KOAgendaView::showDates "); 1029 // qDebug("KOAgendaView::showDates ");
1030 QDate d = start; 1030 QDate d = start;
1031 while (d <= end) { 1031 while (d <= end) {
1032 mSelectedDates.append(d); 1032 mSelectedDates.append(d);
1033 d = d.addDays( 1 ); 1033 d = d.addDays( 1 );
1034 } 1034 }
1035 1035
1036 // and update the view 1036 // and update the view
1037 fillAgenda(); 1037 fillAgenda();
1038} 1038}
1039 1039
1040 1040
1041void KOAgendaView::showEvents(QPtrList<Event>) 1041void KOAgendaView::showEvents(QPtrList<Event>)
1042{ 1042{
1043 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1043 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1044} 1044}
1045 1045
1046void KOAgendaView::changeEventDisplay(Event *, int) 1046void KOAgendaView::changeEventDisplay(Event *, int)
1047{ 1047{
1048 // qDebug("KOAgendaView::changeEventDisplay "); 1048 // qDebug("KOAgendaView::changeEventDisplay ");
1049 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1049 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1050 // this should be re-written to be MUCH smarter. Right now we 1050 // this should be re-written to be MUCH smarter. Right now we
1051 // are just playing dumb. 1051 // are just playing dumb.
1052 fillAgenda(); 1052 fillAgenda();
1053} 1053}
1054 1054
1055void KOAgendaView::fillAgenda(const QDate &) 1055void KOAgendaView::fillAgenda(const QDate &)
1056{ 1056{
1057 // qDebug("KOAgendaView::fillAgenda "); 1057 // qDebug("KOAgendaView::fillAgenda ");
1058 fillAgenda(); 1058 fillAgenda();
1059} 1059}
1060 1060
1061void KOAgendaView::fillAgenda() 1061void KOAgendaView::fillAgenda()
1062{ 1062{
1063 if ( globalFlagBlockStartup ) 1063 if ( globalFlagBlockStartup )
1064 return; 1064 return;
1065 if ( globalFlagBlockAgenda == 1 ) 1065 if ( globalFlagBlockAgenda == 1 )
1066 return; 1066 return;
1067 //if ( globalFlagBlockAgenda == 2 ) 1067 //if ( globalFlagBlockAgenda == 2 )
1068 //globalFlagBlockAgenda = 0; 1068 //globalFlagBlockAgenda = 0;
1069 // globalFlagBlockPainting = false; 1069 // globalFlagBlockPainting = false;
1070 if ( globalFlagBlockAgenda == 0 ) 1070 if ( globalFlagBlockAgenda == 0 )
1071 globalFlagBlockAgenda = 1; 1071 globalFlagBlockAgenda = 1;
1072 // clearView(); 1072 // clearView();
1073 //qDebug("fillAgenda()++++ "); 1073 //qDebug("fillAgenda()++++ ");
1074 globalFlagBlockAgendaItemPaint = 1; 1074 globalFlagBlockAgendaItemPaint = 1;
1075 1075
1076 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1076 mAllDayAgenda->changeColumns(mSelectedDates.count());
1077 mAgenda->changeColumns(mSelectedDates.count()); 1077 mAgenda->changeColumns(mSelectedDates.count());
1078 qApp->processEvents(); 1078 qApp->processEvents();
1079 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1079 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1080 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1080 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1081 setHolidayMasks(); 1081 setHolidayMasks();
1082 1082
1083 //mAgenda->hideUnused(); 1083 //mAgenda->hideUnused();
1084 //mAllDayAgenda->hideUnused(); 1084 //mAllDayAgenda->hideUnused();
1085 1085
1086 // mAgenda->blockNextRepaint( false ); 1086 // mAgenda->blockNextRepaint( false );
1087 // mAgenda->viewport()->repaint(); 1087 // mAgenda->viewport()->repaint();
1088 // mAgenda->blockNextRepaint( true ); 1088 // mAgenda->blockNextRepaint( true );
1089 mMinY.resize(mSelectedDates.count()); 1089 mMinY.resize(mSelectedDates.count());
1090 mMaxY.resize(mSelectedDates.count()); 1090 mMaxY.resize(mSelectedDates.count());
1091 1091
1092 QPtrList<Event> dayEvents; 1092 QPtrList<Event> dayEvents;
1093 1093
1094 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1094 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1095 // Therefore, gtodoset all of them. 1095 // Therefore, gtodoset all of them.
1096 QPtrList<Todo> todos = calendar()->todos(); 1096 QPtrList<Todo> todos = calendar()->todos();
1097 1097
1098 mAgenda->setDateList(mSelectedDates); 1098 mAgenda->setDateList(mSelectedDates);
1099 1099
1100 QDate today = QDate::currentDate(); 1100 QDate today = QDate::currentDate();
1101 1101
1102 DateList::ConstIterator dit; 1102 DateList::ConstIterator dit;
1103 int curCol = 0; 1103 int curCol = 0;
1104 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1104 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1105 QDate currentDate = *dit; 1105 QDate currentDate = *dit;
1106 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1106 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1107 // << endl; 1107 // << endl;
1108 1108
1109 dayEvents = calendar()->events(currentDate,true); 1109 dayEvents = calendar()->events(currentDate,true);
1110 1110
1111 // Default values, which can never be reached 1111 // Default values, which can never be reached
1112 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1112 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1113 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1113 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1114 1114
1115 unsigned int numEvent; 1115 unsigned int numEvent;