Ignore:
Timestamp:
01/20/17 21:46:55 (5 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
ec7fa22
Parents:
ea8416e
Message:

Event favourite is now tristate in the code now and the corresponding buttons are tristate as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.cpp

    rea8416e r7b3cd0e  
    6565        // * image
    6666        // * rest is text, which is 1 line of title with big letters and 2 lines of Presenter and Track
    67         int aux = option.rect.height() - SPACER - mControls[FavouriteControlOn]->image()->height();
     67        int aux = option.rect.height() - SPACER - mControls[FavouriteControlStrong]->image()->height();
    6868        Event *event = static_cast<Event*>(index.internalPointer());
    6969
     
    106106            c->setEnabled(false);
    107107        }
    108         if(event->isFavourite())
    109             mControls[FavouriteControlOn]->paint(painter, option.rect);
    110         else
    111             mControls[FavouriteControlOff]->paint(painter, option.rect);
     108        switch (event->favourite()) {
     109        case Favourite_strong:
     110            mControls[FavouriteControlStrong]->paint(painter, option.rect);
     111            break;
     112        case Favourite_weak:
     113            mControls[FavouriteControlWeak]->paint(painter, option.rect);
     114            break;
     115        case Favourite_no:
     116            mControls[FavouriteControlNo]->paint(painter, option.rect);
     117            break;
     118        }
    112119
    113120        if(event->hasAlarm())
     
    125132        painter->setPen(QPen(event->hasTimeConflict() ? Qt::black : textColor));
    126133        QPointF titlePointF(option.rect.x() + SPACER,
    127                             option.rect.y() + SPACER + mControls[FavouriteControlOn]->image()->height());
     134                            option.rect.y() + SPACER + mControls[FavouriteControlStrong]->image()->height());
    128135        QTime start = event->start().time();
    129136        painter->setFont(fontBig);
     
    189196        painter->setPen(QPen(textColor));
    190197        painter->setFont(fontSmall);
    191         QImage *image = mControls[numFav ? FavouriteControlOn : FavouriteControlOff]->image();
     198        QImage *image = mControls[numFav ? FavouriteControlStrong : FavouriteControlNo]->image();
    192199        QPoint drawPoint =
    193200            option.rect.topRight()
     
    307314{
    308315    // FAVOURITE ICONs
    309     // on
    310     mControls.insert(FavouriteControlOn, new Control(FavouriteControlOn, QString(":icons/favourite-on.png"), NULL));
    311     // off
    312     mControls.insert(FavouriteControlOff, new Control(FavouriteControlOff, QString(":icons/favourite-off.png"), NULL));
     316    // strong
     317    mControls.insert(FavouriteControlStrong, new Control(FavouriteControlStrong, QString(":icons/favourite-on.png"), NULL));
     318    // weak
     319    mControls.insert(FavouriteControlWeak, new Control(FavouriteControlWeak, QString(":icons/favourite-weak.png"), NULL));
     320    // no
     321    mControls.insert(FavouriteControlNo, new Control(FavouriteControlNo, QString(":icons/favourite-off.png"), NULL));
    313322
    314323    // ALARM ICONs
    315324    // on
    316325    mControls.insert(AlarmControlOn,
    317                     new Control(AlarmControlOn, QString(":icons/alarm-on.png"), mControls[FavouriteControlOn]));
     326                    new Control(AlarmControlOn, QString(":icons/alarm-on.png"), mControls[FavouriteControlStrong]));
    318327    // off
    319328    mControls.insert(AlarmControlOff,
    320                     new Control(AlarmControlOff, QString(":icons/alarm-off.png"), mControls[FavouriteControlOff]));
     329                    new Control(AlarmControlOff, QString(":icons/alarm-off.png"), mControls[FavouriteControlNo]));
    321330    // WARNING ICON
    322331    mControls.insert(WarningControl,
     
    339348    int nrofFavs = 0;
    340349    for(int i=0; i<index.model()->rowCount(index); i++)
    341         if(static_cast<Event*>(index.child(i,0).internalPointer())->isFavourite())
     350        if(static_cast<Event*>(index.child(i,0).internalPointer())->favourite() != Favourite_no)
    342351            nrofFavs++;
    343352
Note: See TracChangeset for help on using the changeset viewer.