-rw-r--r-- | korganizer/komonthview.cpp | 88 |
1 files changed, 55 insertions, 33 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 8ee5bc3..050bfb9 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -314,5 +314,6 @@ int MonthViewItem::height(const QListBox *lb) const { + int ret = 10; if ( lb ) - return lb->fontMetrics().lineSpacing()+1; - return 10; + ret = lb->fontMetrics().lineSpacing()+1; + return ret; } @@ -321,25 +322,31 @@ int MonthViewItem::width(const QListBox *lb) const { - int size = PIXMAP_SIZE; - if ( QApplication::desktop()->width() < 300 ) - size = 3; - int x = 1; - if ( KOPrefs::instance()->mMonthShowIcons ) { - if ( mInfo ) { - x += size + 1; - } - if( mRecur ) { - x += size+1; - } - if( mAlarm ) { - x += size+1; + + if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { + int size = PIXMAP_SIZE; + if ( QApplication::desktop()->width() < 300 ) + size = 3; + int x = 1; + if ( KOPrefs::instance()->mMonthShowIcons ) { + if ( mInfo ) { + x += size + 1; + } + if( mRecur ) { + x += size+1; + } + if( mAlarm ) { + x += size+1; + } + if( mReply ) { + x += size+1; + } } - if( mReply ) { - x += size+1; + if( mMultiday ) { + x += size+1+2+size/2; } + return( x + lb->fontMetrics().width( text() ) + 1 ); } - if( mMultiday ) { - x += size+1+2+size/2; - } - - return( x + lb->fontMetrics().width( text() ) + 1 ); + if ( ! lb ) + return 10; + //qDebug("ret wid %d ", lb->width()); + return lb->width(); } @@ -352,3 +359,3 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) - QVBoxLayout *topLayout = new QVBoxLayout( this ); + //QVBoxLayout *topLayout = new QVBoxLayout( this ); @@ -365,3 +372,3 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) mItemList->setLineWidth( 1 ); - topLayout->addWidget( mItemList ); + //topLayout->addWidget( mItemList ); mLabel->raise(); @@ -419,13 +426,16 @@ void MonthViewCell::setMyPalette() if ( mHoliday) { - setPalette( mHolidayPalette ); + mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); + mItemList->setPalette( mHolidayPalette ); } else { if ( mPrimary ) { - setPalette( mPrimaryPalette ); + mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); + mItemList->setPalette( mPrimaryPalette ); } else { - setPalette( mNonPrimaryPalette ); + mItemList->setPalette( mNonPrimaryPalette ); + mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); } } - QPalette pal = palette(); + //QPalette pal = palette(); - mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); + //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); } @@ -676,3 +686,4 @@ void MonthViewCell::finishUpdateCell() mLabel->setText( text ); - resizeEvent( 0 ); + resizeEvent( 0 ); + } @@ -737,4 +748,12 @@ void MonthViewCell::enableScrollBars( bool enabled ) if ( enabled ) { - mItemList->setVScrollBarMode(QScrollView::Auto); + //mItemList->setVScrollBarMode(QScrollView::Auto); mItemList->setHScrollBarMode(QScrollView::Auto); + QListBoxItem *fi = mItemList->firstItem (); + if (fi ) { + int hei = mItemList->numRows () * fi->height(mItemList); + if ( hei < height() - mItemList->horizontalScrollBar()->height () ) + mItemList->setVScrollBarMode(QScrollView::AlwaysOff); + else + mItemList->setVScrollBarMode(QScrollView::Auto); + } } else { @@ -783,3 +802,3 @@ void MonthViewCell::select() -void MonthViewCell::resizeEvent ( QResizeEvent * ) +void MonthViewCell::resizeEvent ( QResizeEvent * e ) { @@ -787,3 +806,4 @@ void MonthViewCell::resizeEvent ( QResizeEvent * ) return; - + //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); + deselect(); int size = height() - mLabel->height() - 2; @@ -796,2 +816,4 @@ void MonthViewCell::resizeEvent ( QResizeEvent * ) //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); + mItemList->resize ( width(), height () ); + } |