-rw-r--r-- | korganizer/komonthview.cpp | 57 | ||||
-rw-r--r-- | korganizer/komonthview.h | 6 |
2 files changed, 18 insertions, 45 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 00e5a6f..aeb3974 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -278,47 +278,26 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) } } -MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) +MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) : QListBoxItem() { - mDisplayHightlighted = false; mblockRepaint = true; - setText( s ); - mMultiday = 0; - mIncidence = incidence; - mDate = qd; - mRecur = false; - mAlarm = false; - mReply = false; - mInfo = false; - mdayPos = 0; isWeekItem = KOPrefs::instance()->mMonthViewWeek; + recycle( incidence, s ); } -void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) +void MonthViewItem::recycle( Incidence *incidence, const QString & s) { mDisplayHightlighted = false; setText( s ); mMultiday = 0; mIncidence = incidence; - mDate = qd; - mRecur = false; - mAlarm = false; - mReply = false; - mInfo = false; - mdayPos = 0; -} -void MonthViewItem::clearData() -{ - mDisplayHightlighted = false; - setText( "" ); - mMultiday = 0; - mIncidence = 0; mRecur = false; mAlarm = false; mReply = false; mInfo = false; mdayPos = 0; } + bool MonthViewItem::setHighlightedFalse() { if ( !mDisplayHightlighted ) @@ -344,7 +323,7 @@ bool MonthViewItem::setHighlighted( Incidence * inc ) } void MonthViewItem::paint(QPainter *p) { - if ( mblockRepaint ) { + if ( mblockRepaint || !mIncidence ) { return; } #if QT_VERSION >= 0x030000 @@ -354,7 +333,7 @@ void MonthViewItem::paint(QPainter *p) #endif int heihei = height( listBox () ); int x = 1; - if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) + if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel ) { if ( mDisplayHightlighted ) sel = true; @@ -395,7 +374,7 @@ void MonthViewItem::paint(QPainter *p) if ( mMultiday ) { int yyy = y+(size/2); int sizeM = size+2; - p->setBrush( QBrush::SolidPattern ); + p->setBrush( QBrush( p->pen().color() ) ); p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; if ( mMultiday == 2 || mMultiday == 3 ) { QPointArray pa ( 3 ); @@ -434,7 +413,7 @@ void MonthViewItem::paint(QPainter *p) } else { int val = td->percentComplete()/20; - p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); + p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); p->drawRect ( x, y-2,7,size+4); x += size + 3; } @@ -668,7 +647,7 @@ void MonthViewCell::startUpdateCell() while ( CurrentAvailItem ) { MonthViewItem *item = CurrentAvailItem; //item->setHighlightedFalse(); - item->clearData(); + item->recycle( 0, ""); CurrentAvailItem = (MonthViewItem *)item->next(); mAvailItemList.append( item ); takeItem ( item ); @@ -764,9 +743,9 @@ int MonthViewCell::insertEvent(Event *event) if ( mAvailItemList.count() ) { item = mAvailItemList.first(); mAvailItemList.remove( item ); - item->recycle( event, mDate, text ); + item->recycle( event, text ); } else { - item = new MonthViewItem( event, mDate, text ); + item = new MonthViewItem( event, text ); } QPalette pal; @@ -794,6 +773,7 @@ int MonthViewCell::insertEvent(Event *event) } else { pal = mStandardPalette ; } + pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); item->setRecur( event->recurrence()->doesRecur() ); item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); @@ -853,9 +833,9 @@ void MonthViewCell::insertTodo(Todo *todo) if ( mAvailItemList.count() ) { item = mAvailItemList.first(); mAvailItemList.remove( item ); - item->recycle( todo, mDate, text ); + item->recycle( todo, text ); } else { - item = new MonthViewItem( todo, mDate, text ); + item = new MonthViewItem( todo, text ); } //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); //item->setPalette( mStandardPalette ); @@ -884,6 +864,7 @@ void MonthViewCell::insertTodo(Todo *todo) } else { pal = mStandardPalette ; } + pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); item->setRecur( todo->recurrence()->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); @@ -1023,13 +1004,7 @@ 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(); + return mDate; } void MonthViewCell::deselect() diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index ac97860..2622d10 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -105,9 +105,8 @@ class KNoScrollListBox: public QListBox class MonthViewItem: public QListBoxItem { public: - MonthViewItem( Incidence *, QDate qd, const QString & title ); - void recycle( Incidence *incidence, QDate qd, const QString & s); - void clearData(); + MonthViewItem( Incidence *,const QString & title ); + void recycle( Incidence *incidence, const QString & s); void setRecur(bool on) { mRecur = on; } void setAlarm(bool on) { mAlarm = on; } void setReply(bool on) { mReply = on; } @@ -123,7 +122,6 @@ class MonthViewItem: public QListBoxItem QPalette palette() const { return mPalette; } bool setHighlightedFalse(); Incidence *incidence() const { return mIncidence; } - QDate incidenceDate() { return mDate; } protected: virtual void paint(QPainter *); |