Changeset b6cd05c for src/mvc


Ignore:
Timestamp:
01/18/10 16:13:01 (12 years ago)
Author:
pavelpa <pavelpa@…>
Branches:
master, qt5
Children:
f6300c7
Parents:
d23aa6a
Message:

added 'alarm' columnt to the 'EVENT' table to signalize
that the event has/hasn't alarm set

Location:
src/mvc
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.cpp

    rd23aa6a rb6cd05c  
    8484
    8585        // draw Controls
     86        // favourite
    8687        if(static_cast<Event*>(index.internalPointer())->isFavourite())
    8788            painter->drawImage(mControls[FavouriteControlOn]->drawPoint(option.rect),*mControls[FavouriteControlOn]->image());
    8889        else
    8990            painter->drawImage(mControls[FavouriteControlOff]->drawPoint(option.rect),*mControls[FavouriteControlOff]->image());
    90         painter->drawImage(mControls[AlarmControlOn]->drawPoint(option.rect),*mControls[AlarmControlOn]->image());
     91        // alarm
     92        if(static_cast<Event*>(index.internalPointer())->hasAlarm())
     93            painter->drawImage(mControls[AlarmControlOn]->drawPoint(option.rect),*mControls[AlarmControlOn]->image());
     94        else
     95            painter->drawImage(mControls[AlarmControlOff]->drawPoint(option.rect),*mControls[AlarmControlOff]->image());
     96        // map
    9197        painter->drawImage(mControls[MapControl]->drawPoint(option.rect),*mControls[MapControl]->image());
    9298    }
     
    225231    // ALARM ICONs
    226232    // on
    227     control = new Control(AlarmControlOn,QString(":icons/alarm-off.png"));
     233    control = new Control(AlarmControlOn,QString(":icons/alarm-on.png"));
    228234    p = mControls[FavouriteControlOn]->drawPoint();
    229235    p.setX(p.x()-control->image()->width()-SPACER);
  • src/mvc/event.cpp

    rd23aa6a rb6cd05c  
    66QString const Event::sTable1Name = QString("event");
    77QString const Event::sTable2Name = QString("virtual_event");
    8 int const Event::sTable1ColCount = 8; // see 'toRecord()' for more details
     8int const Event::sTable1ColCount = 9; // see 'toRecord()' for more details
    99int const Event::sTable2ColCount = 5; // see 'toRecord()' for more details
    1010
     
    1919    << QSqlField("language", QVariant::String)
    2020    << QSqlField("favourite", QVariant::Bool)
     21    << QSqlField("alarm", QVariant::Bool)
    2122    /* 'columns' from Table2 */
    2223    << QSqlField("tag", QVariant::String)
  • src/mvc/event.h

    rd23aa6a rb6cd05c  
    4040    QString language() const { return value("language").toString(); }
    4141    bool isFavourite() const { return value("favourite").toBool(); }
     42    bool hasAlarm() const { return value("alarm").toBool(); }
    4243    // Table 2 : virtual table for FTS (Full Text Search)
    4344    QString tag() const { return value("tag").toString(); }
     
    5657    void setLanguage(const QString& language) { setValue("language", language); }
    5758    void setFavourite(bool favourite) { setValue("favourite", (int)favourite); }
     59    void setHasAlarm(bool alarm) { setValue("alarm", (int)alarm); }
    5860    // Table 2 : virtual table for FTS (Full Text Search)
    5961    void setTag(const QString& tag) { setValue("tag", tag); }
  • src/mvc/eventmodel.cpp

    rd23aa6a rb6cd05c  
    125125        Group group = mGroups[i];
    126126        beginRemoveRows(idx,0,group.mChildCount-1);
    127         bool ok = removeRows(0,group.mChildCount,idx);
     127        removeRows(0,group.mChildCount,idx);
    128128        endRemoveRows();
    129129        //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
     
    148148        Group group = mGroups[i];
    149149        beginRemoveRows(idx,0,group.mChildCount-1);
    150         bool ok = removeRows(0,group.mChildCount,idx);
     150        removeRows(0,group.mChildCount,idx);
    151151        endRemoveRows();
    152152        //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
  • src/mvc/treeview.cpp

    rd23aa6a rb6cd05c  
    5858            {
    5959                // handle Alarm Control clicked
    60                 qDebug() << "ALARM CLICKED: " << qVariantValue<QString>(aIndex.data());
     60                Event event = Event::getById(aIndex.data().toInt(),1);
     61                if(event.hasAlarm())
     62                {
     63                    static_cast<Event*>(aIndex.internalPointer())->setHasAlarm(false); // list of events
     64                    event.setHasAlarm(false); // update DB
     65                }
     66                else
     67                {
     68                    static_cast<Event*>(aIndex.internalPointer())->setHasAlarm(true); // list of events
     69                    event.setHasAlarm(true);
     70                }
     71                qDebug() << " ALARM [" << qVariantValue<QString>(aIndex.data()) << "] -> " << event.hasAlarm();
     72                event.update("alarm");
     73                // since the Alarm icon has changed, update TreeView accordingly
     74                static_cast<EventModel*>(model())->emitDataChangedSignal(aIndex,aIndex);
     75
    6176            }
    6277            break;
Note: See TracChangeset for help on using the changeset viewer.