if(hasParent(index))
{
+ Event *event = static_cast<Event*>(index.internalPointer());
+
+ // determine severity of conflict
+ Favourite eventTimeConflict = event->timeConflict(); // cache value as event->timeConflict is expensive
+ enum ConflictSeverity {csNone, csWeak, csStrong} conflictSeverity;
+ switch (event->favourite()) {
+ case Favourite_strong:
+ conflictSeverity = (eventTimeConflict == Favourite_strong) ? csStrong : csNone;
+ break;
+ case Favourite_weak:
+ conflictSeverity = (eventTimeConflict == Favourite_no) ? csNone : csWeak;
+ break;
+ case Favourite_no:
+ conflictSeverity = csNone;
+ break;
+ }
+
// entry horizontal layout:
// * spacer (aka y position of image)
// * image
// * rest is text, which is 1 line of title with big letters and 2 lines of Presenter and Track
int aux = option.rect.height() - SPACER - mControls[FavouriteControlStrong]->image()->height();
- Event *event = static_cast<Event*>(index.internalPointer());
// font SMALL
QFont fontSmall = option.font;
QFontMetrics fmBigB(fontBigB);
// background (in case of time conflicts)
- if(event->hasTimeConflict()) {
- painter->setBrush(Qt::yellow);
+ if (conflictSeverity != csNone) {
+ painter->setBrush(conflictSeverity == csStrong ? Qt::yellow : QColor("lightyellow"));
painter->setPen(Qt::NoPen);
painter->drawRect(option.rect);
}
else
mControls[AlarmControlOff]->paint(painter, option.rect);
- if(event->hasTimeConflict())
+ if(eventTimeConflict != Favourite_no)
mControls[WarningControl]->paint(painter, option.rect);
// draw texts
// it starts just below the image
// ("position of text" is lower-left angle of the first letter,
// so the first line is actually at the same height as the image)
- painter->setPen(QPen(event->hasTimeConflict() ? Qt::black : textColor));
+ painter->setPen(QPen(conflictSeverity != csNone ? Qt::black : textColor));
QPointF titlePointF(option.rect.x() + SPACER,
option.rect.y() + SPACER + mControls[FavouriteControlStrong]->image()->height());
QTime start = event->start().time();
return mLinksList;
}
-bool Event::hasTimeConflict() const
-{
- if(favourite() == Favourite_no) // if it's not favourite, it can't have time-conflict
- return false;
+Favourite Event::timeConflict() const {
+ if (favourite() == Favourite_no) // if it's not favourite, it can't have time-conflict
+ return Favourite_no;
+
+ QList<Event> events = conflictEvents(id(),conferenceId());
+
+ // find "strongest" conflict
+ Favourite f = Favourite_no;
+ for (int i = 0; i != events.size(); ++i) {
+ switch (events[i].favourite()) {
+ case Favourite_strong: f = Favourite_strong; break;
+ case Favourite_weak: if (f == Favourite_no) f = Favourite_weak; break;
+ case Favourite_no: break;
+ }
+ }
+ return f;
- return conflictEvents(id(),conferenceId()).count() > 0;
}
void Event::cycleFavourite() {
QString language() const { return value("language").toString(); }
Favourite favourite() const { return static_cast<Favourite>(value("favourite").toInt()); }
bool hasAlarm() const { return value("alarm").toBool(); }
- bool hasTimeConflict() const;
+ Favourite timeConflict() const;
QString tag() const { return value("tag").toString(); }
QString title() const { return value("title").toString(); }
QString subtitle() const { return value("subtitle").toString(); }