-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 @@ -273,57 +273,36 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) { QListBox::mousePressEvent(e); if(e->button() == RightButton) { emit rightClick(); } } -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 ) return false; mDisplayHightlighted = false; return true; } @@ -339,27 +318,27 @@ bool MonthViewItem::setHighlighted( Incidence * inc ) return false; mDisplayHightlighted = false; return true; } return false; } void MonthViewItem::paint(QPainter *p) { - if ( mblockRepaint ) { + if ( mblockRepaint || !mIncidence ) { return; } #if QT_VERSION >= 0x030000 bool sel = isSelected(); #else bool sel = selected(); #endif int heihei = height( listBox () ); int x = 1; - if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) + if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel ) { if ( mDisplayHightlighted ) sel = true; p->setBackgroundColor( palette().color( QPalette::Normal, \ sel ? QColorGroup::Highlight : QColorGroup::Background ) ); p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); } @@ -390,17 +369,17 @@ void MonthViewItem::paint(QPainter *p) if ( mReply ) { p->fillRect ( x, y,size,size, Qt::yellow ); x += size + 1; } } 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 ); pa.setPoint (0, x, yyy ); pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); p->drawPolygon( pa ); } @@ -429,17 +408,17 @@ void MonthViewItem::paint(QPainter *p) if ( td->isCompleted() ) { int half = size/2; p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; x += half+half + 4; } 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; } } QFontMetrics fm = p->fontMetrics(); int yPos; int pmheight = size; if( pmheight < fm.height() ) @@ -663,17 +642,17 @@ void MonthViewCell::startUpdateCell() } else { setLineWidth( 1 ); } MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); //clear(); while ( CurrentAvailItem ) { MonthViewItem *item = CurrentAvailItem; //item->setHighlightedFalse(); - item->clearData(); + item->recycle( 0, ""); CurrentAvailItem = (MonthViewItem *)item->next(); mAvailItemList.append( item ); takeItem ( item ); } #ifdef DESKTOP_VERSION QToolTip::remove(this); #endif @@ -759,19 +738,19 @@ int MonthViewCell::insertEvent(Event *event) if ( useToolTips && ! event->location().isEmpty() ) { mToolTipText += " (" + event->location() +")"; } MonthViewItem *item ; 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; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = event->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); @@ -789,16 +768,17 @@ int MonthViewCell::insertEvent(Event *event) } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } 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() ); item->setMoreInfo( event->description().length() > 0 ); #ifdef DESKTOP_VERSION Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, KOPrefs::instance()->email()); if ( me != 0 ) { @@ -848,19 +828,19 @@ void MonthViewCell::insertTodo(Todo *todo) text += " "; } } text += todo->summary(); MonthViewItem *item ; 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 ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = todo->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { @@ -879,16 +859,17 @@ void MonthViewCell::insertTodo(Todo *todo) } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } else { pal = mStandardPalette ; } + pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); item->setPalette( pal ); item->setRecur( todo->recurrence()->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); insertItem( item , count()); #ifdef DESKTOP_VERSION mToolTip.append( text ); #endif @@ -1018,23 +999,17 @@ Incidence *MonthViewCell::selectedIncidence() 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(); + return mDate; } void MonthViewCell::deselect() { clearSelection(); enableScrollBars( false ); // updateCell(); } diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index ac97860..2622d10 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -100,35 +100,33 @@ class KNoScrollListBox: public QListBox bool resetOnFocusIn; KNOWhatsThis * mWT; }; 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; } void setMoreInfo(bool on) { mInfo = on; } void setMultiDay(int type) { mMultiday = type; } int multiDay() { return mMultiday; } void setMultiDayPos(int type) { mdayPos = type; } int gettMultiDayPos() { return mdayPos; } void setBlockRepaint(bool on) { mblockRepaint = on; } bool setHighlighted( Incidence * ); void setPalette(const QPalette &p) { mPalette = p; } QPalette palette() const { return mPalette; } bool setHighlightedFalse(); Incidence *incidence() const { return mIncidence; } - QDate incidenceDate() { return mDate; } protected: virtual void paint(QPainter *); virtual int height(const QListBox *) const; virtual int width(const QListBox *) const; private: int mdayPos; |