-rw-r--r-- | library/datebookmonth.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/library/datebookmonth.cpp b/library/datebookmonth.cpp index 421559e..013ab66 100644 --- a/library/datebookmonth.cpp +++ b/library/datebookmonth.cpp @@ -502,163 +502,174 @@ class DayItemMonthPrivate public: DayItemMonthPrivate() {}; ~DayItemMonthPrivate() { mDayEvents.clear(); }; QValueList<EffectiveEvent> mDayEvents; }; DayItemMonth::DayItemMonth( QTable *table, EditType et, const QString &t ) : QTableItem( table, et, t ) { d = new DayItemMonthPrivate(); } DayItemMonth::~DayItemMonth() { daysEvents.clear(); delete d; } void DayItemMonth::setEvents( const QValueList<EffectiveEvent> &effEv ) { d->mDayEvents = effEv; } void DayItemMonth::clearEffEvents() { d->mDayEvents.clear(); } void DayItemMonth::paint( QPainter *p, const QColorGroup &cg, const QRect &cr, bool selected ) { p->save(); QColorGroup g( cg ); g.setBrush( QColorGroup::Base, back ); g.setColor( QColorGroup::Text, forg ); if ( selected ) p->setPen( g.highlightedText() ); else p->setPen( g.text() ); QValueStack<int> normalLine; QValueStack<int> repeatLine; QValueStack<int> travelLine; bool normalAllDay = FALSE; bool repeatAllDay = FALSE; bool travelAllDay = FALSE; + bool holidayAllDay = FALSE; QValueListIterator<EffectiveEvent> itDays = d->mDayEvents.begin(); for ( ; itDays != d->mDayEvents.end(); ++itDays ) { int w = cr.width(); Event ev = (*itDays).event(); int f = (*itDays).start().hour(); // assume Effective event int t = (*itDays).end().hour(); // is truncated. if (ev.isAllDay()) { - if (!ev.hasRepeat()) + if (!ev.hasRepeat()) { normalAllDay = TRUE; - else + if (!ev.isValidUid()) { + holidayAllDay = TRUE; + } + } else { repeatAllDay = TRUE; + } } else { int sLine, eLine; if (f == 0) sLine = 0; else if (f < 8 ) sLine = 1; else if (f >= 17) sLine = w - 4; else { sLine = (f - 8) * (w - 8); if (sLine) sLine /= 8; sLine += 4; } if (t == 23) eLine = w; else if (t < 8) eLine = 4; else if (t >= 17) eLine = w - 1; else { eLine = (t - 8) * (w - 8); if (eLine) eLine /= 8; eLine += 4; } if (!ev.hasRepeat()) { normalLine.push(sLine); normalLine.push(eLine); } else { repeatLine.push(sLine); repeatLine.push(eLine); } } } // draw the background - if (normalAllDay || repeatAllDay || travelAllDay) { + if (normalAllDay || repeatAllDay || travelAllDay || holidayAllDay) { p->save(); if (normalAllDay) if (repeatAllDay) { p->fillRect( 0, 0, cr.width(), cr.height() / 2, colorNormalLight ); p->fillRect( 0, cr.height() / 2, cr.width(), cr.height() / 2, colorRepeatLight ); - } else + } else { + if (!holidayAllDay) { p->fillRect( 0, 0, cr.width(), cr.height(), colorNormalLight ); - else if (repeatAllDay) + } else { + p->fillRect( 0, 0, cr.width(), cr.height(), + QColor(0,220,0) ); + } + } else if (repeatAllDay) { p->fillRect( 0, 0, cr.width(), cr.height(), colorRepeatLight ); + } } else { p->fillRect( 0, 0, cr.width(), cr.height(), selected ? g.brush( QColorGroup::Highlight ) : g.brush( QColorGroup::Base ) ); } // The lines // now for the lines. int h = 5; int y = cr.height() / 2 - h; while(normalLine.count() >= 2) { int x2 = normalLine.pop(); int x1 = normalLine.pop(); if (x2 < x1 + 2) x2 = x1 + 2; p->fillRect(x1, y, x2 - x1, h, colorNormal); } y += h; while(repeatLine.count() >= 2) { int x2 = repeatLine.pop(); int x1 = repeatLine.pop(); if (x2 < x1 + 2) x2 = x1 + 2; p->fillRect(x1, y, x2 - x1, h, colorRepeat); } // Finally, draw the number. QFont f = p->font(); f.setPointSize( ( f.pointSize() / 3 ) * 2 ); p->setFont( f ); QFontMetrics fm( f ); p->drawText( 1, 1 + fm.ascent(), QString::number( day() ) ); p->restore(); } void DayItemMonth::setType( Calendar::Day::Type t ) { switch ( t ) { case Calendar::Day::PrevMonth: case Calendar::Day::NextMonth: |