Changeset 7b3cd0e for src/mvc/event.cpp


Ignore:
Timestamp:
01/20/17 21:46:55 (6 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/event.cpp

    rea8416e r7b3cd0e  
    9191           ( start >= :s1 AND ( start + duration ) < :e1 ) \
    9292        OR ( ( start + duration ) > :s2 AND start < :e2 ) ) \
    93         AND favourite = 1 AND NOT id = :id ORDER BY start, duration");
     93        AND favourite >= 1 AND NOT id = :id ORDER BY start, duration");
    9494    query.bindValue(":conf", event.conferenceId());
    9595    query.bindValue(":s1", convertToDb(event.start(), QVariant::DateTime));
     
    117117    QDateTime dayStart(date, conference.dayChangeTime(), Qt::UTC);
    118118    QSqlQuery query;
    119     query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start >= :start AND start < :end AND favourite = 1 ORDER BY start, duration"));
     119    query.prepare(selectQuery() + QString("WHERE xid_conference = :conf AND start >= :start AND start < :end AND favourite >= 1 ORDER BY start, duration"));
    120120    query.bindValue(":conf", conferenceId);
    121121    query.bindValue(":start", dayStart.toTime_t());
     
    195195bool Event::hasTimeConflict() const
    196196{
    197     if(!isFavourite()) // if it's not favourite, it can't have time-conflict
     197    if(favourite() == Favourite_no) // if it's not favourite, it can't have time-conflict
    198198        return false;
    199199
    200     return conflictEvents(id(),conferenceId()).count() > 0 ? true : false;
     200    return conflictEvents(id(),conferenceId()).count() > 0;
     201}
     202
     203void Event::cycleFavourite() {
     204    switch (favourite()) {
     205        case Favourite_no: setFavourite(Favourite_strong); break;
     206        case Favourite_strong: setFavourite(Favourite_weak); break;
     207        case Favourite_weak: setFavourite(Favourite_no); break;
     208    }
    201209}
    202210
Note: See TracChangeset for help on using the changeset viewer.