summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
authorzautrix <zautrix>2005-04-04 20:24:30 (UTC)
committer zautrix <zautrix>2005-04-04 20:24:30 (UTC)
commitc408fcb55de18d1e3e1d20803c3885e3074cfaa4 (patch) (unidiff)
tree092f6e385210a9fa7bd625c2e0cae3ceba68f513 /korganizer/komonthview.cpp
parent8e7f4812c4ad239b6a17cce8aa84c00274ced4df (diff)
downloadkdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.zip
kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.gz
kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.bz2
month view fixes
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp116
1 files changed, 64 insertions, 52 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9f7db69..1ed288b 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -75,48 +75,74 @@ private:
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff);
87} 89}
88KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
89{ 91{
90 92
91} 93}
92 94
93 95
94void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 96void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
95{ 97{
96 QListBox::focusInEvent ( e ); 98 QListBox::focusInEvent ( e );
97 QListBoxItem * i = item ( 0 ); 99 QListBoxItem * i = item ( 0 );
98 if ( i && resetOnFocusIn ) { 100 if ( i && resetOnFocusIn ) {
99 setCurrentItem( i ); 101 setCurrentItem( i );
100 setSelected ( 0, true ); 102 setSelected ( 0, true );
101 } 103 }
102 resetOnFocusIn = true; 104 resetOnFocusIn = true;
105
106 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
107 QListBoxItem *fi = firstItem ();
108 if (fi ) {
109 int ihei = fi->height( this );
110 int hei = numRows () * ihei;
111 if ( hei < height() - horizontalScrollBar()->height () ) {
112 setVScrollBarMode(QScrollView::AlwaysOff);
113 }
114 else
115 setVScrollBarMode(QScrollView::Auto);
116 if ( ihei *3 > height() ) {
117 setHScrollBarMode(QScrollView::AlwaysOff);
118 }
119 else {
120 setHScrollBarMode(QScrollView::Auto);
121 }
122 } else {
123 setVScrollBarMode(QScrollView::Auto);
124 setHScrollBarMode(QScrollView::Auto);
125 }
126 }
103} 127}
104void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 128void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
105{ 129{
106 int i = currentItem (); 130 int i = currentItem ();
107 if ( i >= 0 ) { 131 if ( i >= 0 ) {
108 setSelected ( i, false ); 132 setSelected ( i, false );
109 } 133 }
110 QListBox::focusOutEvent ( e ); 134 QListBox::focusOutEvent ( e );
135 setVScrollBarMode(QScrollView::AlwaysOff);
136 setHScrollBarMode(QScrollView::AlwaysOff);
111} 137}
112 138
113QString KNoScrollListBox::getWhatsThisText(QPoint p) 139QString KNoScrollListBox::getWhatsThisText(QPoint p)
114{ 140{
115 QListBoxItem* item = itemAt ( p ); 141 QListBoxItem* item = itemAt ( p );
116 if ( ! item ) { 142 if ( ! item ) {
117 return i18n("Click in the cell\nto add an event!"); 143 return i18n("Click in the cell\nto add an event!");
118 } 144 }
119 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 145 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
120 KOPrefs::instance()->mWTshowDetails, 146 KOPrefs::instance()->mWTshowDetails,
121 KOPrefs::instance()->mWTshowCreated, 147 KOPrefs::instance()->mWTshowCreated,
122 KOPrefs::instance()->mWTshowChanged); 148 KOPrefs::instance()->mWTshowChanged);
@@ -234,24 +260,25 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
234MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 260MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
235 : QListBoxItem() 261 : QListBoxItem()
236{ 262{
237 mblockRepaint = true; 263 mblockRepaint = true;
238 setText( s ); 264 setText( s );
239 mMultiday = 0; 265 mMultiday = 0;
240 mIncidence = incidence; 266 mIncidence = incidence;
241 mDate = qd; 267 mDate = qd;
242 mRecur = false; 268 mRecur = false;
243 mAlarm = false; 269 mAlarm = false;
244 mReply = false; 270 mReply = false;
245 mInfo = false; 271 mInfo = false;
272 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
246 //qDebug("NEWWWWWWWWWWWWW "); 273 //qDebug("NEWWWWWWWWWWWWW ");
247} 274}
248void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 275void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
249{ 276{
250 setText( s ); 277 setText( s );
251 mMultiday = 0; 278 mMultiday = 0;
252 mIncidence = incidence; 279 mIncidence = incidence;
253 mDate = qd; 280 mDate = qd;
254 mRecur = false; 281 mRecur = false;
255 mAlarm = false; 282 mAlarm = false;
256 mReply = false; 283 mReply = false;
257 mInfo = false; 284 mInfo = false;
@@ -371,25 +398,25 @@ void MonthViewItem::paint(QPainter *p)
371 398
372int MonthViewItem::height(const QListBox *lb) const 399int MonthViewItem::height(const QListBox *lb) const
373{ 400{
374 int ret = 10; 401 int ret = 10;
375 if ( lb ) 402 if ( lb )
376 ret = lb->fontMetrics().lineSpacing()+1; 403 ret = lb->fontMetrics().lineSpacing()+1;
377 return ret; 404 return ret;
378} 405}
379 406
380int MonthViewItem::width(const QListBox *lb) const 407int MonthViewItem::width(const QListBox *lb) const
381{ 408{
382 409
383 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 410 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
384 int size = PIXMAP_SIZE; 411 int size = PIXMAP_SIZE;
385 if ( QApplication::desktop()->width() < 300 ) 412 if ( QApplication::desktop()->width() < 300 )
386 size = 3; 413 size = 3;
387 int x = 1; 414 int x = 1;
388 if ( KOPrefs::instance()->mMonthShowIcons ) { 415 if ( KOPrefs::instance()->mMonthShowIcons ) {
389 if ( mInfo ) { 416 if ( mInfo ) {
390 x += size + 1; 417 x += size + 1;
391 } 418 }
392 if( mRecur ) { 419 if( mRecur ) {
393 x += size+1; 420 x += size+1;
394 } 421 }
395 if( mAlarm ) { 422 if( mAlarm ) {
@@ -406,26 +433,24 @@ int MonthViewItem::width(const QListBox *lb) const
406 } 433 }
407 if ( ! lb ) 434 if ( ! lb )
408 return 10; 435 return 10;
409 //qDebug("ret wid %d ", lb->width()); 436 //qDebug("ret wid %d ", lb->width());
410 return lb->width(); 437 return lb->width();
411} 438}
412 439
413 440
414MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 441MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
415 : KNoScrollListBox( par ), 442 : KNoScrollListBox( par ),
416 mMonthView( parent ) 443 mMonthView( parent )
417{ 444{
418
419 mCurrentAvailItem = 0;
420 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 445 //QVBoxLayout *topLayout = new QVBoxLayout( this );
421 currentPalette = 0; 446 currentPalette = 0;
422 // mLabel = new QLabel( this );QPushButton 447 // mLabel = new QLabel( this );QPushButton
423 mLabel = new QPushButton( this ); 448 mLabel = new QPushButton( this );
424 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 449 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
425 //mLabel->setLineWidth( 1 ); 450 //mLabel->setLineWidth( 1 );
426 //mLabel->setAlignment( AlignCenter ); 451 //mLabel->setAlignment( AlignCenter );
427 mLabel->setFlat( true ); 452 mLabel->setFlat( true );
428 mLabel->setFocusPolicy(NoFocus); 453 mLabel->setFocusPolicy(NoFocus);
429 //mItemList = new KNoScrollListBox( this ); 454 //mItemList = new KNoScrollListBox( this );
430 setMinimumSize( 10, 10 ); 455 setMinimumSize( 10, 10 );
431 setFrameStyle( QFrame::Panel | QFrame::Plain ); 456 setFrameStyle( QFrame::Panel | QFrame::Plain );
@@ -563,46 +588,51 @@ void MonthViewCell::startUpdateCell()
563 if ( !isVisible() ){ 588 if ( !isVisible() ){
564 return; 589 return;
565 } 590 }
566 */ 591 */
567 // qDebug("MonthViewCell::updateCell() "); 592 // qDebug("MonthViewCell::updateCell() ");
568 setPrimary( mDate.month()%2 ); 593 setPrimary( mDate.month()%2 );
569 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 594 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
570 if ( mDate == QDate::currentDate() ) { 595 if ( mDate == QDate::currentDate() ) {
571 setLineWidth( 3 ); 596 setLineWidth( 3 );
572 } else { 597 } else {
573 setLineWidth( 1 ); 598 setLineWidth( 1 );
574 } 599 }
575 mCurrentAvailItem = (MonthViewItem*) firstItem (); 600 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
576 //clear(); 601 //clear();
602 while ( CurrentAvailItem ) {
603 MonthViewItem *item = CurrentAvailItem;
604 CurrentAvailItem = (MonthViewItem *)item->next();
605 mAvailItemList.append( item );
606 takeItem ( item );
607 }
577 608
578#ifdef DESKTOP_VERSION 609#ifdef DESKTOP_VERSION
579 QToolTip::remove(this); 610 QToolTip::remove(this);
580#endif 611#endif
581 mToolTip.clear(); 612 mToolTip.clear();
582 //qApp->processEvents(); 613 //qApp->processEvents();
583#if 0 614#if 0
584 if ( !mHolidayString.isEmpty() ) { 615 if ( !mHolidayString.isEmpty() ) {
585 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 616 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
586 item->setPalette( mHolidayPalette ); 617 item->setPalette( mHolidayPalette );
587 insertItem( item ); 618 insertItem( item );
588 mToolTip.append ( mHolidayString ); 619 mToolTip.append ( mHolidayString );
589 } 620 }
590#endif 621#endif
591} 622}
592 623
593void MonthViewCell::insertEvent(Event *event) 624void MonthViewCell::insertEvent(Event *event)
594{ 625{
595 QString mToolTipText; 626 QString mToolTipText;
596 bool insertNewItem = false;
597 setFocusPolicy(WheelFocus); 627 setFocusPolicy(WheelFocus);
598 if ( !(event->doesRecur() == Recurrence::rNone) ) { 628 if ( !(event->doesRecur() == Recurrence::rNone) ) {
599 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 629 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
600 return; 630 return;
601 else 631 else
602 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 632 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
603 return; 633 return;
604 } 634 }
605 635
606 if ( event->isHoliday()) { 636 if ( event->isHoliday()) {
607 setHoliday( true ); 637 setHoliday( true );
608 if ( mDate.dayOfWeek() == 7 ) 638 if ( mDate.dayOfWeek() == 7 )
@@ -643,39 +673,33 @@ void MonthViewCell::insertEvent(Event *event)
643 } else { 673 } else {
644 if (event->doesFloat()) { 674 if (event->doesFloat()) {
645 text = event->summary(); 675 text = event->summary();
646 mToolTipText += text; 676 mToolTipText += text;
647 } 677 }
648 else { 678 else {
649 text = KGlobal::locale()->formatTime(event->dtStart().time()); 679 text = KGlobal::locale()->formatTime(event->dtStart().time());
650 text += " " + event->summary(); 680 text += " " + event->summary();
651 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 681 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
652 } 682 }
653 } 683 }
654 MonthViewItem *item ; 684 MonthViewItem *item ;
655 if ( mCurrentAvailItem ) { 685
656 item = mCurrentAvailItem; 686 if ( mAvailItemList.count() ) {
657 mCurrentAvailItem = (MonthViewItem*) item->next(); 687 item = mAvailItemList.first();
688 mAvailItemList.remove( item );
658 item->recycle( event, mDate, text ); 689 item->recycle( event, mDate, text );
659 } else { 690 } else {
660 if ( mAvailItemList.count() ) { 691 item = new MonthViewItem( event, mDate, text );
661 item = mAvailItemList.first();
662 mAvailItemList.remove( item );
663 item->recycle( event, mDate, text );
664 insertNewItem = true;
665 } else {
666 insertNewItem = true;
667 item = new MonthViewItem( event, mDate, text );
668 }
669 } 692 }
693
670 QPalette pal; 694 QPalette pal;
671 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 695 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
672 QStringList categories = event->categories(); 696 QStringList categories = event->categories();
673 QString cat = categories.first(); 697 QString cat = categories.first();
674 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 698 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
675 pal = getPalette(); 699 pal = getPalette();
676 if (cat.isEmpty()) { 700 if (cat.isEmpty()) {
677 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 701 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
678 } else { 702 } else {
679 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 703 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
680 } 704 }
681 705
@@ -697,55 +721,45 @@ void MonthViewCell::insertEvent(Event *event)
697#ifdef DESKTOP_VERSION 721#ifdef DESKTOP_VERSION
698 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 722 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
699 KOPrefs::instance()->email()); 723 KOPrefs::instance()->email());
700 if ( me != 0 ) { 724 if ( me != 0 ) {
701 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 725 if ( me->status() == Attendee::NeedsAction && me->RSVP())
702 item->setReply(true && multiday < 2); 726 item->setReply(true && multiday < 2);
703 else 727 else
704 item->setReply(false); 728 item->setReply(false);
705 } else 729 } else
706 item->setReply(false); 730 item->setReply(false);
707#endif 731#endif
708 item->setMultiDay( multiday ); 732 item->setMultiDay( multiday );
709 if ( insertNewItem) 733 insertItem( item );
710 insertItem( item );
711 mToolTip.append( mToolTipText ); 734 mToolTip.append( mToolTipText );
712} 735}
713void MonthViewCell::insertTodo(Todo *todo) 736void MonthViewCell::insertTodo(Todo *todo)
714{ 737{
715 bool insertNewItem = false;
716 setFocusPolicy(WheelFocus); 738 setFocusPolicy(WheelFocus);
717 QString text; 739 QString text;
718 if (todo->hasDueDate()) { 740 if (todo->hasDueDate()) {
719 if (!todo->doesFloat()) { 741 if (!todo->doesFloat()) {
720 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 742 text += KGlobal::locale()->formatTime(todo->dtDue().time());
721 text += " "; 743 text += " ";
722 } 744 }
723 } 745 }
724 text += todo->summary(); 746 text += todo->summary();
725 MonthViewItem *item ; 747 MonthViewItem *item ;
726 if ( mCurrentAvailItem ) { 748 if ( mAvailItemList.count() ) {
727 item = mCurrentAvailItem; 749 item = mAvailItemList.first();
728 mCurrentAvailItem = (MonthViewItem*) item->next(); 750 mAvailItemList.remove( item );
729 item->recycle( todo, mDate, text ); 751 item->recycle( todo, mDate, text );
730 } else { 752 } else {
731 if ( mAvailItemList.count() ) { 753 item = new MonthViewItem( todo, mDate, text );
732 item = mAvailItemList.first();
733 mAvailItemList.remove( item );
734 item->recycle( todo, mDate, text );
735 insertNewItem = true;
736 } else {
737 insertNewItem = true;
738 item = new MonthViewItem( todo, mDate, text );
739 }
740 } 754 }
741 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 755 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
742 //item->setPalette( mStandardPalette ); 756 //item->setPalette( mStandardPalette );
743 QPalette pal; 757 QPalette pal;
744 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 758 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
745 QStringList categories = todo->categories(); 759 QStringList categories = todo->categories();
746 QString cat = categories.first(); 760 QString cat = categories.first();
747 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 761 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
748 pal = getPalette(); 762 pal = getPalette();
749 if (cat.isEmpty()) { 763 if (cat.isEmpty()) {
750 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 764 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
751 } else { 765 } else {
@@ -758,45 +772,39 @@ void MonthViewCell::insertTodo(Todo *todo)
758 } else { 772 } else {
759 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 773 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
760 } 774 }
761 } 775 }
762 776
763 } else { 777 } else {
764 pal = mStandardPalette ; 778 pal = mStandardPalette ;
765 } 779 }
766 item->setPalette( pal ); 780 item->setPalette( pal );
767 item->setRecur( todo->recurrence()->doesRecur() ); 781 item->setRecur( todo->recurrence()->doesRecur() );
768 item->setAlarm( todo->isAlarmEnabled() ); 782 item->setAlarm( todo->isAlarmEnabled() );
769 item->setMoreInfo( todo->description().length() > 0 ); 783 item->setMoreInfo( todo->description().length() > 0 );
770 if ( insertNewItem) 784 insertItem( item );
771 insertItem( item );
772 mToolTip.append( text ); 785 mToolTip.append( text );
773} 786}
774void MonthViewCell::repaintfinishUpdateCell() 787void MonthViewCell::repaintfinishUpdateCell()
775{ 788{
776 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 789 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
777 while ( mitem ) { 790 while ( mitem ) {
778 mitem->setBlockRepaint( false ); 791 mitem->setBlockRepaint( false );
779 updateItem ( mitem ); 792 updateItem ( mitem );
780 mitem = (MonthViewItem *)mitem->next(); 793 mitem = (MonthViewItem *)mitem->next();
781 } 794 }
782} 795}
783void MonthViewCell::finishUpdateCell() 796void MonthViewCell::finishUpdateCell()
784{ 797{
785 while ( mCurrentAvailItem ) { 798
786 MonthViewItem *item = mCurrentAvailItem;
787 mCurrentAvailItem = (MonthViewItem *)item->next();
788 mAvailItemList.append( item );
789 takeItem ( item );
790 }
791 799
792 800
793#ifdef DESKTOP_VERSION 801#ifdef DESKTOP_VERSION
794 if (mToolTip.count() > 0 ) { 802 if (mToolTip.count() > 0 ) {
795 mToolTip.sort(); 803 mToolTip.sort();
796 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 804 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
797 } 805 }
798#endif 806#endif
799 sort(); 807 sort();
800 //setMyPalette(); 808 //setMyPalette();
801 setMyPalette(); 809 setMyPalette();
802 810
@@ -852,38 +860,42 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
852 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 860 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
853 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 861 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
854 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 862 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
855 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 863 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
856 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 864 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
857 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 865 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
858 } 866 }
859 //updateCell(); 867 //updateCell();
860} 868}
861 869
862void MonthViewCell::enableScrollBars( bool enabled ) 870void MonthViewCell::enableScrollBars( bool enabled )
863{ 871{
872
873 return;
864 if ( enabled ) { 874 if ( enabled ) {
865 QListBoxItem *fi = firstItem (); 875 QListBoxItem *fi = firstItem ();
866 if (fi ) { 876 if (fi ) {
867 int ihei = fi->height( this ); 877 int ihei = fi->height( this );
868 int hei = numRows () * ihei; 878 int hei = numRows () * ihei;
869 if ( hei < height() - horizontalScrollBar()->height () ) { 879 if ( hei < height() - horizontalScrollBar()->height () ) {
870 setVScrollBarMode(QScrollView::AlwaysOff); 880 setVScrollBarMode(QScrollView::AlwaysOff);
871 } 881 }
872 else 882 else
873 setVScrollBarMode(QScrollView::Auto); 883 setVScrollBarMode(QScrollView::Auto);
874 if ( ihei *3 > height() ) 884 if ( ihei *3 > height() ) {
875 setHScrollBarMode(QScrollView::AlwaysOff); 885 setHScrollBarMode(QScrollView::AlwaysOff);
876 else 886 }
887 else {
877 setHScrollBarMode(QScrollView::Auto); 888 setHScrollBarMode(QScrollView::Auto);
889 }
878 } else { 890 } else {
879 setVScrollBarMode(QScrollView::Auto); 891 setVScrollBarMode(QScrollView::Auto);
880 setHScrollBarMode(QScrollView::Auto); 892 setHScrollBarMode(QScrollView::Auto);
881 } 893 }
882 } else { 894 } else {
883 setVScrollBarMode(QScrollView::AlwaysOff); 895 setVScrollBarMode(QScrollView::AlwaysOff);
884 setHScrollBarMode(QScrollView::AlwaysOff); 896 setHScrollBarMode(QScrollView::AlwaysOff);
885 } 897 }
886} 898}
887 899
888Incidence *MonthViewCell::selectedIncidence() 900Incidence *MonthViewCell::selectedIncidence()
889{ 901{
@@ -972,25 +984,24 @@ void MonthViewCell::defaultAction( QListBoxItem *item )
972} 984}
973void MonthViewCell::showDay() 985void MonthViewCell::showDay()
974{ 986{
975 emit showDaySignal( date() ); 987 emit showDaySignal( date() );
976} 988}
977void MonthViewCell::newEvent() 989void MonthViewCell::newEvent()
978{ 990{
979 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 991 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
980 emit newEventSignal( dt ); 992 emit newEventSignal( dt );
981} 993}
982void MonthViewCell::cellClicked( QListBoxItem *item ) 994void MonthViewCell::cellClicked( QListBoxItem *item )
983{ 995{
984 static QListBoxItem * lastClicked = 0;
985 if ( item == 0 ) { 996 if ( item == 0 ) {
986 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 997 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
987 emit newEventSignal( dt ); 998 emit newEventSignal( dt );
988 return; 999 return;
989 } 1000 }
990 /* 1001 /*
991 if ( lastClicked ) 1002 if ( lastClicked )
992 if ( ! item ) { 1003 if ( ! item ) {
993 if ( lastClicked->listBox() != item->listBox() ) 1004 if ( lastClicked->listBox() != item->listBox() )
994 lastClicked->listBox()->clearSelection(); 1005 lastClicked->listBox()->clearSelection();
995 } 1006 }
996 */ 1007 */
@@ -1082,41 +1093,41 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1082 KOWeekButton *label = new KOWeekButton( mMonthView ); 1093 KOWeekButton *label = new KOWeekButton( mMonthView );
1083 label->setFocusPolicy(NoFocus); 1094 label->setFocusPolicy(NoFocus);
1084 label->setFont(bfont); 1095 label->setFont(bfont);
1085 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1096 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1086 label->setFlat(true); 1097 label->setFlat(true);
1087 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1098 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1088 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1099 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1089 //label->setLineWidth(1); 1100 //label->setLineWidth(1);
1090 //label->setAlignment(AlignCenter); 1101 //label->setAlignment(AlignCenter);
1091 mWeekLabels.insert( i, label ); 1102 mWeekLabels.insert( i, label );
1092 } 1103 }
1093 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1104 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1094 mWeekLabels[0]->setFocusPolicy(WheelFocus); 1105 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1095 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1106 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1096 1107
1097 for( i = 0; i < 1+1; i++ ) { 1108 for( i = 0; i < 1+1; i++ ) {
1098 KOWeekButton *label = new KOWeekButton( mWeekView ); 1109 KOWeekButton *label = new KOWeekButton( mWeekView );
1099 label->setFocusPolicy(NoFocus); 1110 label->setFocusPolicy(NoFocus);
1100 label->setFont(bfont); 1111 label->setFont(bfont);
1101 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1112 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1102 label->setFlat(true); 1113 label->setFlat(true);
1103 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1114 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1104 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1115 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1105 //label->setLineWidth(1); 1116 //label->setLineWidth(1);
1106 //label->setAlignment(AlignCenter); 1117 //label->setAlignment(AlignCenter);
1107 mWeekLabelsW.insert( i, label ); 1118 mWeekLabelsW.insert( i, label );
1108 } 1119 }
1109 mWeekLabelsW[1]->setText( i18n("W")); 1120 mWeekLabelsW[1]->setText( i18n("W"));
1110 mWeekLabelsW[0]->setFocusPolicy(WheelFocus); 1121 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1111 1122
1112 1123
1113 int row, col; 1124 int row, col;
1114 mCells.resize( mNumCells ); 1125 mCells.resize( mNumCells );
1115 for( row = 0; row < mNumWeeks; ++row ) { 1126 for( row = 0; row < mNumWeeks; ++row ) {
1116 for( col = 0; col < mDaysPerWeek; ++col ) { 1127 for( col = 0; col < mDaysPerWeek; ++col ) {
1117 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1128 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1118 mCells.insert( row * mDaysPerWeek + col, cell ); 1129 mCells.insert( row * mDaysPerWeek + col, cell );
1119 1130
1120 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1131 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1121 SLOT( defaultAction( Incidence * ) ) ); 1132 SLOT( defaultAction( Incidence * ) ) );
1122 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1133 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
@@ -1389,25 +1400,25 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
1389 updateView(); 1400 updateView();
1390} 1401}
1391 1402
1392void KOMonthView::showEvents(QPtrList<Event>) 1403void KOMonthView::showEvents(QPtrList<Event>)
1393{ 1404{
1394 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1405 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1395} 1406}
1396 1407
1397void KOMonthView::changeEventDisplay(Event *, int) 1408void KOMonthView::changeEventDisplay(Event *, int)
1398{ 1409{
1399 // this should be re-written to be much more efficient, but this 1410 // this should be re-written to be much more efficient, but this
1400 // quick-and-dirty-hack gets the job done for right now. 1411 // quick-and-dirty-hack gets the job done for right now.
1401 qDebug("KOMonthView::changeEventDisplay "); 1412 //qDebug("KOMonthView::changeEventDisplay ");
1402 updateView(); 1413 updateView();
1403} 1414}
1404 1415
1405void KOMonthView::updateView() 1416void KOMonthView::updateView()
1406{ 1417{
1407 1418
1408 if ( !updatePossible ) 1419 if ( !updatePossible )
1409 return; 1420 return;
1410 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1421 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1411 //QTime ti; 1422 //QTime ti;
1412 //ti.start(); 1423 //ti.start();
1413 clearSelection(); 1424 clearSelection();
@@ -1519,32 +1530,33 @@ void KOMonthView::updateView()
1519 1530
1520 //qDebug("KOMonthView::updateView() "); 1531 //qDebug("KOMonthView::updateView() ");
1521 processSelectionChange(); 1532 processSelectionChange();
1522 // qDebug("---------------------------------------------------------------------+ "); 1533 // qDebug("---------------------------------------------------------------------+ ");
1523 (*cells)[0]->setFocus(); 1534 (*cells)[0]->setFocus();
1524#endif 1535#endif
1525 1536
1526 //qDebug("update time %d ", ti.elapsed()); 1537 //qDebug("update time %d ", ti.elapsed());
1527} 1538}
1528 1539
1529void KOMonthView::setKeyBoardFocus() 1540void KOMonthView::setKeyBoardFocus()
1530{ 1541{
1542 //qDebug("KOMonthView::setKeyBoardFocus() ");
1531 bool shootAgain = false; 1543 bool shootAgain = false;
1532 if ( mShowWeekView ) { 1544 if ( mShowWeekView ) {
1533 shootAgain = !mWeekLabelsW[0]->hasFocus(); 1545 shootAgain = !mWeekLabelsW[1]->hasFocus();
1534 mWeekLabelsW[0]->setFocus(); 1546 mWeekLabelsW[1]->setFocus();
1535 } 1547 }
1536 else { 1548 else {
1537 shootAgain = !mWeekLabels[0]->hasFocus(); 1549 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1538 mWeekLabels[0]->setFocus(); 1550 mWeekLabels[mNumWeeks]->setFocus();
1539 } 1551 }
1540 if ( shootAgain ) { 1552 if ( shootAgain ) {
1541 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1553 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1542 } 1554 }
1543} 1555}
1544void KOMonthView::setKeyBFocus() 1556void KOMonthView::setKeyBFocus()
1545{ 1557{
1546 //qDebug("KOMonthView::setKeyBFocus() "); 1558 //qDebug("KOMonthView::setKeyBFocus() ");
1547 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1559 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1548} 1560}
1549void KOMonthView::resizeEvent(QResizeEvent * e) 1561void KOMonthView::resizeEvent(QResizeEvent * e)
1550{ 1562{