Changeset 7b3cd0e in confclerk_git


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.

Location:
src
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • src/gui/eventdialog.cpp

    rea8416e r7b3cd0e  
    8989    connect(alarmButton, SIGNAL(clicked()), SLOT(alarmClicked()));
    9090
    91     if(event.isFavourite())
    92     {
    93         favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
    94     }
     91    updateFavouriteButton(event);
    9592
    9693    if(event.hasAlarm())
     
    103100{
    104101    Event event = Event::getById(mEventId, mConferenceId);
     102    event.cycleFavourite();
     103    event.update("favourite");
     104    updateFavouriteButton(event);
    105105
     106    // 'conflicts' list may have changed
    106107    QList<Event> conflicts = Event::conflictEvents(event.id(), mConferenceId);
    107     if(event.isFavourite())
    108     {
    109         event.setFavourite(false);
    110         favouriteButton->setIcon(QIcon(":/icons/favourite-off.png"));
    111     }
    112     else
    113     {
    114         event.setFavourite(true);
    115         favouriteButton->setIcon(QIcon(":/icons/favourite-on.png"));
    116     }
    117     event.update("favourite");
    118 
    119     if(event.isFavourite())
    120     {
    121         // event has became 'favourite' and so 'conflicts' list may have changed
    122         conflicts = Event::conflictEvents(event.id(), mConferenceId);
    123     }
    124108
    125109    // have to emit 'eventChanged' signal on all events in conflict
     
    163147}
    164148
     149
     150void EventDialog::updateFavouriteButton(const Event& event) {
     151    switch (event.favourite()) {
     152        case Favourite_no: favouriteButton->setIcon(QIcon(":/icons/favourite-off.png")); break;
     153        case Favourite_weak: favouriteButton->setIcon(QIcon(":/icons/favourite-weak.png")); break;
     154        case Favourite_strong: favouriteButton->setIcon(QIcon(":/icons/favourite-on.png")); break;
     155    }
     156}
     157
  • src/gui/eventdialog.h

    rea8416e r7b3cd0e  
    3939    int mConferenceId;
    4040    int mEventId;
     41    void updateFavouriteButton(const Event& event);
    4142};
    4243
  • src/icons.qrc

    rea8416e r7b3cd0e  
    1010        <file>icons/today.png</file>
    1111        <file>icons/favourite-off.png</file>
     12        <file>icons/favourite-weak.png</file>
    1213        <file>icons/favourite-on.png</file>
    1314        <file>icons/alarm-on.png</file>
  • 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
  • src/mvc/delegate.h

    rea8416e r7b3cd0e  
    3232        {
    3333            ControlNone = 0,
    34             FavouriteControlOn,
    35             FavouriteControlOff,
     34            FavouriteControlStrong,
     35            FavouriteControlWeak,
     36            FavouriteControlNo,
    3637            AlarmControlOn,
    3738            AlarmControlOff,
  • 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
  • src/mvc/event.h

    rea8416e r7b3cd0e  
    8989    void setFavourite(Favourite favourite) { setValue("favourite", (int) favourite); }
    9090    void setFavourite(bool favourite) { setFavourite(favourite ? Favourite_strong : Favourite_no); } // deprecated
     91    void cycleFavourite();
    9192    void setHasAlarm(bool alarm) { setValue("alarm", (int)((alarm))); }
    9293    void setTag(const QString& tag) { setValue("tag", tag); }
  • src/mvc/treeview.cpp

    rea8416e r7b3cd0e  
    6565    switch(delegate->whichControlClicked(aIndex,aPoint))
    6666    {
    67         case Delegate::FavouriteControlOn:
    68         case Delegate::FavouriteControlOff:
     67        case Delegate::FavouriteControlStrong:
     68        case Delegate::FavouriteControlWeak:
     69        case Delegate::FavouriteControlNo:
    6970            {
    7071                // handle Favourite Control clicked
     
    7273
    7374                QList<Event> conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
    74                 event.setFavourite(!event.isFavourite());
     75                event.cycleFavourite();
    7576                event.update("favourite");
    7677
    77                 if(event.isFavourite())
    78                 {
    79                     // event has became 'favourite' and so 'conflicts' list may have changed
    80                     conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
    81                 }
     78                // event has became 'favourite' and so 'conflicts' list may have changed
     79                conflicts = Event::conflictEvents(event.id(),Conference::activeConference());
    8280
    8381                // have to emit 'eventChanged' signal on all events in conflict
Note: See TracChangeset for help on using the changeset viewer.