-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 @@ -85,4 +85,6 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) mWT = new KNOWhatsThis(this); resetOnFocusIn = true; + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } KNoScrollListBox::~KNoScrollListBox() @@ -101,4 +103,26 @@ 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); + } + } } void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) @@ -108,5 +132,7 @@ void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) setSelected ( i, false ); } - QListBox::focusOutEvent ( e ); + QListBox::focusOutEvent ( e ); + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } @@ -244,4 +270,5 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) mReply = false; mInfo = false; + isWeekItem = KOPrefs::instance()->mMonthViewWeek; //qDebug("NEWWWWWWWWWWWWW "); } @@ -381,5 +408,5 @@ int MonthViewItem::width(const QListBox *lb) const { - if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { + if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { int size = PIXMAP_SIZE; if ( QApplication::desktop()->width() < 300 ) @@ -416,6 +443,4 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) mMonthView( parent ) { - - mCurrentAvailItem = 0; //QVBoxLayout *topLayout = new QVBoxLayout( this ); currentPalette = 0; @@ -573,6 +598,12 @@ void MonthViewCell::startUpdateCell() setLineWidth( 1 ); } - mCurrentAvailItem = (MonthViewItem*) firstItem (); - //clear(); + MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); + //clear(); + while ( CurrentAvailItem ) { + MonthViewItem *item = CurrentAvailItem; + CurrentAvailItem = (MonthViewItem *)item->next(); + mAvailItemList.append( item ); + takeItem ( item ); + } #ifdef DESKTOP_VERSION @@ -594,5 +625,4 @@ void MonthViewCell::insertEvent(Event *event) { QString mToolTipText; - bool insertNewItem = false; setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { @@ -653,19 +683,13 @@ 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; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { @@ -707,11 +731,9 @@ void MonthViewCell::insertEvent(Event *event) #endif item->setMultiDay( multiday ); - if ( insertNewItem) - insertItem( item ); + insertItem( item ); mToolTip.append( mToolTipText ); } void MonthViewCell::insertTodo(Todo *todo) { - bool insertNewItem = false; setFocusPolicy(WheelFocus); QString text; @@ -724,18 +746,10 @@ void MonthViewCell::insertTodo(Todo *todo) text += todo->summary(); 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 ); } //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); @@ -768,6 +782,5 @@ void MonthViewCell::insertTodo(Todo *todo) item->setAlarm( todo->isAlarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); - if ( insertNewItem) - insertItem( item ); + insertItem( item ); mToolTip.append( text ); } @@ -783,10 +796,5 @@ void MonthViewCell::repaintfinishUpdateCell() void MonthViewCell::finishUpdateCell() { - while ( mCurrentAvailItem ) { - MonthViewItem *item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem *)item->next(); - mAvailItemList.append( item ); - takeItem ( item ); - } + @@ -862,4 +870,6 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false void MonthViewCell::enableScrollBars( bool enabled ) { + + return; if ( enabled ) { QListBoxItem *fi = firstItem (); @@ -872,8 +882,10 @@ void MonthViewCell::enableScrollBars( bool enabled ) else setVScrollBarMode(QScrollView::Auto); - if ( ihei *3 > height() ) + if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); - else + } + else { setHScrollBarMode(QScrollView::Auto); + } } else { setVScrollBarMode(QScrollView::Auto); @@ -982,5 +994,4 @@ void MonthViewCell::newEvent() void MonthViewCell::cellClicked( QListBoxItem *item ) { - static QListBoxItem * lastClicked = 0; if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); @@ -1092,5 +1103,5 @@ 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")); @@ -1108,5 +1119,5 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) } mWeekLabelsW[1]->setText( i18n("W")); - mWeekLabelsW[0]->setFocusPolicy(WheelFocus); + mWeekLabelsW[1]->setFocusPolicy(WheelFocus); @@ -1399,5 +1410,5 @@ void KOMonthView::changeEventDisplay(Event *, int) // this should be re-written to be much more efficient, but this // quick-and-dirty-hack gets the job done for right now. - qDebug("KOMonthView::changeEventDisplay "); + //qDebug("KOMonthView::changeEventDisplay "); updateView(); } @@ -1529,12 +1540,13 @@ void KOMonthView::updateView() 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(); } if ( shootAgain ) { diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e04cdf5..e962756 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -60,5 +60,6 @@ class KOWeekButton : public QPushButton signals: void selectWeekNum ( int ); -private: +private: + void focusInEvent ( QFocusEvent * ){;} int mNumber; void keyPressEvent ( QKeyEvent * e ) @@ -123,4 +124,5 @@ class MonthViewItem: public QListBoxItem private: + bool isWeekItem; bool mblockRepaint; int mMultiday; @@ -196,5 +198,4 @@ public slots: private: - MonthViewItem* mCurrentAvailItem; QPtrList <MonthViewItem> mAvailItemList; KOMonthView *mMonthView; |