- Timestamp:
- 01/20/17 23:04:17 (6 years ago)
- Branches:
- master, qt5
- Children:
- 81d87d7
- Parents:
- ec7fa22
- Location:
- src/mvc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mvc/delegate.cpp
rec7fa22 r1343ea4 61 61 if(hasParent(index)) 62 62 { 63 Event *event = static_cast<Event*>(index.internalPointer()); 64 65 // determine severity of conflict 66 Favourite eventTimeConflict = event->timeConflict(); // cache value as event->timeConflict is expensive 67 enum ConflictSeverity {csNone, csWeak, csStrong} conflictSeverity; 68 switch (event->favourite()) { 69 case Favourite_strong: 70 conflictSeverity = (eventTimeConflict == Favourite_strong) ? csStrong : csNone; 71 break; 72 case Favourite_weak: 73 conflictSeverity = (eventTimeConflict == Favourite_no) ? csNone : csWeak; 74 break; 75 case Favourite_no: 76 conflictSeverity = csNone; 77 break; 78 } 79 63 80 // entry horizontal layout: 64 81 // * spacer (aka y position of image) … … 66 83 // * rest is text, which is 1 line of title with big letters and 2 lines of Presenter and Track 67 84 int aux = option.rect.height() - SPACER - mControls[FavouriteControlStrong]->image()->height(); 68 Event *event = static_cast<Event*>(index.internalPointer());69 85 70 86 // font SMALL … … 89 105 90 106 // background (in case of time conflicts) 91 if (event->hasTimeConflict()) {92 painter->setBrush( Qt::yellow);107 if (conflictSeverity != csNone) { 108 painter->setBrush(conflictSeverity == csStrong ? Qt::yellow : QColor("lightyellow")); 93 109 painter->setPen(Qt::NoPen); 94 110 painter->drawRect(option.rect); … … 123 139 mControls[AlarmControlOff]->paint(painter, option.rect); 124 140 125 if(event ->hasTimeConflict())141 if(eventTimeConflict != Favourite_no) 126 142 mControls[WarningControl]->paint(painter, option.rect); 127 143 … … 130 146 // ("position of text" is lower-left angle of the first letter, 131 147 // so the first line is actually at the same height as the image) 132 painter->setPen(QPen( event->hasTimeConflict()? Qt::black : textColor));148 painter->setPen(QPen(conflictSeverity != csNone ? Qt::black : textColor)); 133 149 QPointF titlePointF(option.rect.x() + SPACER, 134 150 option.rect.y() + SPACER + mControls[FavouriteControlStrong]->image()->height()); -
src/mvc/event.cpp
rec7fa22 r1343ea4 193 193 } 194 194 195 bool Event::hasTimeConflict() const 196 { 197 if(favourite() == Favourite_no) // if it's not favourite, it can't have time-conflict 198 return false; 199 200 return conflictEvents(id(),conferenceId()).count() > 0; 195 Favourite Event::timeConflict() const { 196 if (favourite() == Favourite_no) // if it's not favourite, it can't have time-conflict 197 return Favourite_no; 198 199 QList<Event> events = conflictEvents(id(),conferenceId()); 200 201 // find "strongest" conflict 202 Favourite f = Favourite_no; 203 for (int i = 0; i != events.size(); ++i) { 204 switch (events[i].favourite()) { 205 case Favourite_strong: f = Favourite_strong; break; 206 case Favourite_weak: if (f == Favourite_no) f = Favourite_weak; break; 207 case Favourite_no: break; 208 } 209 } 210 return f; 211 201 212 } 202 213 -
src/mvc/event.h
rec7fa22 r1343ea4 66 66 Favourite favourite() const { return static_cast<Favourite>(value("favourite").toInt()); } 67 67 bool hasAlarm() const { return value("alarm").toBool(); } 68 bool hasTimeConflict() const;68 Favourite timeConflict() const; 69 69 QString tag() const { return value("tag").toString(); } 70 70 QString title() const { return value("title").toString(); }
Note: See TracChangeset
for help on using the changeset viewer.