-rw-r--r-- | korganizer/komonthview.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 12233ee..9085775 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -453,128 +453,133 @@ void MonthViewCell::setMyPalette() } else { if ( mPrimary ) { if ( currentPalette == 2 ) return; mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); //mLabel->setPalette( mPrimaryPalette ); setPalette( mPrimaryPalette ); currentPalette = 2; } else { if ( currentPalette == 3 ) return; setPalette( mNonPrimaryPalette ); mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); //mLabel->setPalette( mNonPrimaryPalette );; currentPalette = 3; } } //QPalette pal = palette(); //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); } QPalette MonthViewCell::getPalette () { if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) return mStandardPalette; if ( mHoliday) { return mHolidayPalette ; } else { if ( mPrimary ) { return mPrimaryPalette ; } } return mNonPrimaryPalette; } bool MonthViewCell::isPrimary() const { return mPrimary; } void MonthViewCell::setHoliday( bool holiday ) { mHoliday = holiday; //setMyPalette(); } void MonthViewCell::setHoliday( const QString &holiday ) { mHolidayString = holiday; if ( !holiday.isEmpty() ) { setHoliday( true ); } } void MonthViewCell::startUpdateCell() { setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { mitem->setBlockRepaint( true ); mitem = (MonthViewItem *)mitem->next(); } + if ( mAvailItemList.count() > 20 ) { + mAvailItemList.setAutoDelete( true ); + mAvailItemList.clear(); + mAvailItemList.setAutoDelete( false ); + } /* if ( !isVisible() ){ return; } */ // qDebug("MonthViewCell::updateCell() "); setPrimary( mDate.month()%2 ); setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); if ( mDate == QDate::currentDate() ) { setLineWidth( 3 ); } else { setLineWidth( 1 ); } mCurrentAvailItem = (MonthViewItem*) firstItem (); //clear(); #ifdef DESKTOP_VERSION QToolTip::remove(this); #endif mToolTip.clear(); //qApp->processEvents(); #if 0 if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); insertItem( item ); mToolTip.append ( mHolidayString ); } #endif } void MonthViewCell::insertEvent(Event *event) { QString mToolTipText; bool insertNewItem = false; setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return; } if ( event->isHoliday()) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) setLineWidth( 3 ); } QString text; int multiday = 0;// 1 = start, 2 = midddle, 3 = end day if (event->isMultiDay()) { QString prefix = "<->";multiday = 2; QString time; if ( event->doesRecur() ) { if ( event->recursOn( mDate) ) { prefix ="->" ;multiday = 1; } else { int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); if ( event->recursOn( mDate.addDays( -days)) ) { prefix ="<-" ;multiday = 3; } } @@ -756,136 +761,136 @@ void MonthViewCell::finishUpdateCell() setMyPalette(); resizeEvent( 0 ); } void MonthViewCell::updateCell() { //qDebug("MonthViewCell::updateCell() "); if ( !mMonthView->isUpdatePossible() ) return; startUpdateCell(); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); Event *event; for( event = events.first(); event; event = events.next() ) { // for event insertEvent(event); } // insert due todos QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { insertTodo( todo ); } finishUpdateCell(); // if ( isVisible()) //qApp->processEvents(); } void MonthViewCell::updateConfig( bool bigFont ) // = false { if ( bigFont ) { QFont fo = KOPrefs::instance()->mMonthViewFont; int ps = fo.pointSize() + 2; if ( ps < 18 ) ps += 2; fo.setPointSize( ps ); setFont( fo ); } else setFont( KOPrefs::instance()->mMonthViewFont ); QFontMetrics fm( font() ); mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); mHolidayPalette = mStandardPalette; mPrimaryPalette = mStandardPalette; mNonPrimaryPalette = mStandardPalette; if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); } //updateCell(); } void MonthViewCell::enableScrollBars( bool enabled ) { if ( enabled ) { - QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); int hei = numRows () * ihei; - if ( hei < height() - horizontalScrollBar()->height () ) + if ( hei < height() - horizontalScrollBar()->height () ) { setVScrollBarMode(QScrollView::AlwaysOff); - else + } + else setVScrollBarMode(QScrollView::Auto); if ( ihei *3 > height() ) setHScrollBarMode(QScrollView::AlwaysOff); else setHScrollBarMode(QScrollView::Auto); } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } } Incidence *MonthViewCell::selectedIncidence() { int index = currentItem(); if ( index < 0 ) return 0; MonthViewItem *mitem = static_cast<MonthViewItem *>( item( index ) ); if ( !mitem ) return 0; return mitem->incidence(); } QDate MonthViewCell::selectedIncidenceDate() { QDate qd; int index = currentItem(); if ( index < 0 ) return qd; MonthViewItem *mitem = static_cast<MonthViewItem *>( item( index ) ); if ( !mitem ) return qd; return mitem->incidenceDate(); } void MonthViewCell::deselect() { clearSelection(); enableScrollBars( false ); // updateCell(); } void MonthViewCell::select() { ;// updateCell(); } void MonthViewCell::resizeEvent ( QResizeEvent * e ) { if ( !mMonthView->isUpdatePossible() ) return; //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); deselect(); mLabel->setMaximumHeight( height() - lineWidth()*2 ); QString text; mLabel->setText( text ); bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |