-rw-r--r-- | korganizer/komonthview.cpp | 116 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
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 @@ -86,2 +86,4 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) resetOnFocusIn = true; + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } @@ -102,2 +104,24 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) resetOnFocusIn = true; + + if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { + QListBoxItem *fi = firstItem (); + if (fi ) { + int ihei = fi->height( this ); + int hei = numRows () * ihei; + if ( hei < height() - horizontalScrollBar()->height () ) { + setVScrollBarMode(QScrollView::AlwaysOff); + } + else + setVScrollBarMode(QScrollView::Auto); + if ( ihei *3 > height() ) { + setHScrollBarMode(QScrollView::AlwaysOff); + } + else { + setHScrollBarMode(QScrollView::Auto); + } + } else { + setVScrollBarMode(QScrollView::Auto); + setHScrollBarMode(QScrollView::Auto); + } + } } @@ -109,3 +133,5 @@ void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) } - QListBox::focusOutEvent ( e ); + QListBox::focusOutEvent ( e ); + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } @@ -245,2 +271,3 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) mInfo = false; + isWeekItem = KOPrefs::instance()->mMonthViewWeek; //qDebug("NEWWWWWWWWWWWWW "); @@ -382,3 +409,3 @@ int MonthViewItem::width(const QListBox *lb) const - if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { + if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { int size = PIXMAP_SIZE; @@ -417,4 +444,2 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) { - - mCurrentAvailItem = 0; //QVBoxLayout *topLayout = new QVBoxLayout( this ); @@ -574,4 +599,10 @@ void MonthViewCell::startUpdateCell() } - mCurrentAvailItem = (MonthViewItem*) firstItem (); - //clear(); + MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); + //clear(); + while ( CurrentAvailItem ) { + MonthViewItem *item = CurrentAvailItem; + CurrentAvailItem = (MonthViewItem *)item->next(); + mAvailItemList.append( item ); + takeItem ( item ); + } @@ -595,3 +626,2 @@ void MonthViewCell::insertEvent(Event *event) QString mToolTipText; - bool insertNewItem = false; setFocusPolicy(WheelFocus); @@ -654,17 +684,11 @@ void MonthViewCell::insertEvent(Event *event) MonthViewItem *item ; - if ( mCurrentAvailItem ) { - item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem*) item->next(); + + if ( mAvailItemList.count() ) { + item = mAvailItemList.first(); + mAvailItemList.remove( item ); item->recycle( event, mDate, text ); } else { - if ( mAvailItemList.count() ) { - item = mAvailItemList.first(); - mAvailItemList.remove( item ); - item->recycle( event, mDate, text ); - insertNewItem = true; - } else { - insertNewItem = true; - item = new MonthViewItem( event, mDate, text ); - } + item = new MonthViewItem( event, mDate, text ); } + QPalette pal; @@ -708,4 +732,3 @@ void MonthViewCell::insertEvent(Event *event) item->setMultiDay( multiday ); - if ( insertNewItem) - insertItem( item ); + insertItem( item ); mToolTip.append( mToolTipText ); @@ -714,3 +737,2 @@ void MonthViewCell::insertTodo(Todo *todo) { - bool insertNewItem = false; setFocusPolicy(WheelFocus); @@ -725,16 +747,8 @@ void MonthViewCell::insertTodo(Todo *todo) MonthViewItem *item ; - if ( mCurrentAvailItem ) { - item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem*) item->next(); + if ( mAvailItemList.count() ) { + item = mAvailItemList.first(); + mAvailItemList.remove( item ); item->recycle( todo, mDate, text ); } else { - if ( mAvailItemList.count() ) { - item = mAvailItemList.first(); - mAvailItemList.remove( item ); - item->recycle( todo, mDate, text ); - insertNewItem = true; - } else { - insertNewItem = true; - item = new MonthViewItem( todo, mDate, text ); - } + item = new MonthViewItem( todo, mDate, text ); } @@ -769,4 +783,3 @@ void MonthViewCell::insertTodo(Todo *todo) item->setMoreInfo( todo->description().length() > 0 ); - if ( insertNewItem) - insertItem( item ); + insertItem( item ); mToolTip.append( text ); @@ -784,8 +797,3 @@ void MonthViewCell::finishUpdateCell() { - while ( mCurrentAvailItem ) { - MonthViewItem *item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem *)item->next(); - mAvailItemList.append( item ); - takeItem ( item ); - } + @@ -863,2 +871,4 @@ void MonthViewCell::enableScrollBars( bool enabled ) { + + return; if ( enabled ) { @@ -873,6 +883,8 @@ void MonthViewCell::enableScrollBars( bool enabled ) setVScrollBarMode(QScrollView::Auto); - if ( ihei *3 > height() ) + if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); - else + } + else { setHScrollBarMode(QScrollView::Auto); + } } else { @@ -983,3 +995,2 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) { - static QListBoxItem * lastClicked = 0; if ( item == 0 ) { @@ -1093,3 +1104,3 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) mWeekLabels[mNumWeeks]->setText( i18n("W")); - mWeekLabels[0]->setFocusPolicy(WheelFocus); + mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); @@ -1109,3 +1120,3 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) mWeekLabelsW[1]->setText( i18n("W")); - mWeekLabelsW[0]->setFocusPolicy(WheelFocus); + mWeekLabelsW[1]->setFocusPolicy(WheelFocus); @@ -1400,3 +1411,3 @@ void KOMonthView::changeEventDisplay(Event *, int) // quick-and-dirty-hack gets the job done for right now. - qDebug("KOMonthView::changeEventDisplay "); + //qDebug("KOMonthView::changeEventDisplay "); updateView(); @@ -1530,10 +1541,11 @@ void KOMonthView::setKeyBoardFocus() { + //qDebug("KOMonthView::setKeyBoardFocus() "); bool shootAgain = false; if ( mShowWeekView ) { - shootAgain = !mWeekLabelsW[0]->hasFocus(); - mWeekLabelsW[0]->setFocus(); + shootAgain = !mWeekLabelsW[1]->hasFocus(); + mWeekLabelsW[1]->setFocus(); } else { - shootAgain = !mWeekLabels[0]->hasFocus(); - mWeekLabels[0]->setFocus(); + shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); + mWeekLabels[mNumWeeks]->setFocus(); } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e04cdf5..e962756 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -61,3 +61,4 @@ class KOWeekButton : public QPushButton void selectWeekNum ( int ); -private: +private: + void focusInEvent ( QFocusEvent * ){;} int mNumber; @@ -124,2 +125,3 @@ class MonthViewItem: public QListBoxItem private: + bool isWeekItem; bool mblockRepaint; @@ -197,3 +199,2 @@ public slots: private: - MonthViewItem* mCurrentAvailItem; QPtrList <MonthViewItem> mAvailItemList; |