Ignore:
Timestamp:
01/20/17 23:04:17 (5 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
81d87d7
Parents:
ec7fa22
Message:

Now the conflict severity is drawn.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.cpp

    rec7fa22 r1343ea4  
    6161    if(hasParent(index))
    6262    {
     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
    6380        // entry horizontal layout:
    6481        // * spacer (aka y position of image)
     
    6683        // * rest is text, which is 1 line of title with big letters and 2 lines of Presenter and Track
    6784        int aux = option.rect.height() - SPACER - mControls[FavouriteControlStrong]->image()->height();
    68         Event *event = static_cast<Event*>(index.internalPointer());
    6985
    7086        // font SMALL
     
    89105
    90106        // 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"));
    93109            painter->setPen(Qt::NoPen);
    94110            painter->drawRect(option.rect);
     
    123139            mControls[AlarmControlOff]->paint(painter, option.rect);
    124140
    125         if(event->hasTimeConflict())
     141        if(eventTimeConflict != Favourite_no)
    126142            mControls[WarningControl]->paint(painter, option.rect);
    127143
     
    130146        // ("position of text" is lower-left angle of the first letter,
    131147        //  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));
    133149        QPointF titlePointF(option.rect.x() + SPACER,
    134150                            option.rect.y() + SPACER + mControls[FavouriteControlStrong]->image()->height());
Note: See TracChangeset for help on using the changeset viewer.