summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp116
-rw-r--r--korganizer/komonthview.h5
2 files changed, 67 insertions, 54 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9f7db69..1ed288b 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -84,6 +84,8 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
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{
@@ -100,6 +102,28 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
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{
@@ -107,7 +131,9 @@ void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
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)
@@ -243,6 +269,7 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
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)
@@ -380,7 +407,7 @@ int MonthViewItem::height(const QListBox *lb) const
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;
@@ -415,8 +442,6 @@ MonthViewCell::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
@@ -572,8 +597,14 @@ void MonthViewCell::startUpdateCell()
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);
@@ -593,7 +624,6 @@ void MonthViewCell::startUpdateCell()
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 )
@@ -652,21 +682,15 @@ void MonthViewCell::insertEvent(Event *event)
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();
@@ -706,13 +730,11 @@ void MonthViewCell::insertEvent(Event *event)
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()) {
@@ -723,20 +745,12 @@ void MonthViewCell::insertTodo(Todo *todo)
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 );
@@ -767,8 +781,7 @@ void MonthViewCell::insertTodo(Todo *todo)
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()
@@ -782,12 +795,7 @@ void MonthViewCell::repaintfinishUpdateCell()
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
@@ -861,6 +869,8 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
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 ) {
@@ -871,10 +881,12 @@ void MonthViewCell::enableScrollBars( bool enabled )
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);
@@ -981,7 +993,6 @@ void MonthViewCell::newEvent()
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 );
@@ -1091,7 +1102,7 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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++ ) {
@@ -1107,7 +1118,7 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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;
@@ -1398,7 +1409,7 @@ void 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
@@ -1528,14 +1539,15 @@ void KOMonthView::updateView()
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() ) );
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e04cdf5..e962756 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -59,7 +59,8 @@ class KOWeekButton : public QPushButton
59 int getWeekNum() { return mNumber;} 59 int getWeekNum() { return mNumber;}
60 signals: 60 signals:
61 void selectWeekNum ( int ); 61 void selectWeekNum ( int );
62private: 62private:
63 void focusInEvent ( QFocusEvent * ){;}
63 int mNumber; 64 int mNumber;
64 void keyPressEvent ( QKeyEvent * e ) 65 void keyPressEvent ( QKeyEvent * e )
65 { 66 {
@@ -122,6 +123,7 @@ class MonthViewItem: public QListBoxItem
122 virtual int width(const QListBox *) const; 123 virtual int width(const QListBox *) const;
123 124
124 private: 125 private:
126 bool isWeekItem;
125 bool mblockRepaint; 127 bool mblockRepaint;
126 int mMultiday; 128 int mMultiday;
127 bool mRecur; 129 bool mRecur;
@@ -195,7 +197,6 @@ public slots:
195 void newEvent(); 197 void newEvent();
196 198
197 private: 199 private:
198 MonthViewItem* mCurrentAvailItem;
199 QPtrList <MonthViewItem> mAvailItemList; 200 QPtrList <MonthViewItem> mAvailItemList;
200 KOMonthView *mMonthView; 201 KOMonthView *mMonthView;
201 int currentPalette; 202 int currentPalette;