Changeset b6cd05c


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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/alarm/alarm.cpp

    rd23aa6a rb6cd05c  
    8484}
    8585
     86bool Alarm::hasEventAlarm(int aEventId)
     87{
     88    cookie_t *list = 0;
     89    cookie_t cookie = 0;
     90    alarm_event_t *event = 0;
     91
     92    bool eventHasAlarm = false;
     93
     94    // query the APPID's list of alarms
     95    if( (list = alarmd_event_query(0,0, 0,0, APPID)) != 0 ) // query OK
     96    {
     97        for( int i = 0; (cookie = list[i]) != 0; ++i )
     98        {
     99            alarm_event_delete(event);
     100
     101            // get the event for specified alarm cookie (alarmId)
     102            if( (event = alarmd_event_get(cookie)) == 0 )
     103            {
     104                // should we inform user about it ???
     105                continue;
     106            }
     107
     108            if(aEventId==atoi(alarm_event_get_message(event)))
     109            {
     110                eventHasAlarm = true;
     111                break;
     112            }
     113        }
     114    }
     115    else
     116    {
     117        // query failed
     118    }
     119
     120    free(list);
     121    alarm_event_delete(event);
     122
     123    return eventHasAlarm;
     124}
     125
  • src/alarm/alarm.h

    rd23aa6a rb6cd05c  
    2020        int addAlarm(int aEventId, const QDateTime &aDateTime);
    2121        void deleteAlarm(int aEventId);
     22        static bool hasEventAlarm(int aEventId);
    2223    signals:
    2324        void alarmAdded(int aEventId);
  • 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;
  • src/sql/sqlengine.cpp

    rd23aa6a rb6cd05c  
    9191        // VIRTUAL_EVENT is for Full-Text-Serach Support
    9292        QDateTime startDateTime = QDateTime(QDate::fromString(aEvent["date"],DATE_FORMAT),QTime::fromString(aEvent["start"],TIME_FORMAT));
    93         QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8'") \
     93        QString values = QString("'%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8', '%9'") \
    9494                         .arg(aEvent["conference_id"]) \
    9595                         .arg(aEvent["id"]) \
     
    9999                         .arg(aEvent["type"]) \
    100100                         .arg(aEvent["language"]) \
    101                          .arg("0"); // not favourite when added
    102 
    103         QString query = QString("INSERT INTO EVENT (xid_conference, id, start, duration, xid_activity, type, language, favourite) VALUES (%1)").arg(values);
     101                         .arg("0") \
     102                         .arg("0");
     103
     104        QString query = QString("INSERT INTO EVENT (xid_conference, id, start, duration, xid_activity, type, language, favourite, alarm) VALUES (%1)").arg(values);
    104105        QSqlQuery result (query, db);
    105106        //LOG_AUTOTEST(query);
     
    120121        result2.bindValue(3,aEvent["description"]);
    121122        result2.exec();
    122 
    123          //LOG_AUTOTEST(query2);
    124         qDebug() << query2;
     123        //LOG_AUTOTEST(query2);
    125124    }
    126125}
     
    235234            language VARCHAR, \
    236235            favourite INTEGER DEFAULT 0, \
     236            alarm INTEGER DEFAULT 0, \
    237237            PRIMARY KEY (xid_conference,id), \
    238238            FOREIGN KEY(xid_conference) REFERENCES CONFERENCE(id) \
    239239            FOREIGN KEY(xid_activity) REFERENCES ACTIVITY(id))");
    240240
    241         // TBD Virtual tables compatibility (waiting for Marek). Temporary non virtual VIRTUAL_TABLE below: To be deleted
    242 /*        query.exec("CREATE VIRTUAL TABLE VIRTUAL_EVENT using fts3 ( \
    243             xid_conference INTEGER  NOT NULL, \
    244             id INTEGER NOT NULL , \
    245             tag VARCHAR,title VARCHAR NOT NULL , \
    246             subtitle VARCHAR, \
    247             abstract VARCHAR, \
    248             description VARCHAR, \
    249             PRIMARY KEY (xid_conference,id))");
    250 */
     241#ifdef MAEMO
     242        // TBD: MAEMO Virtual tables compatibility (waiting for Marek).
     243        // MAEMO sqlite Qt driver doesn't provide FTS support by default - use the following HACK
    251244        query.exec("CREATE TABLE VIRTUAL_EVENT ( \
    252245            xid_conference INTEGER  NOT NULL, \
     
    257250            description VARCHAR, \
    258251            PRIMARY KEY (xid_conference,id))");
     252#else
     253        query.exec("CREATE VIRTUAL TABLE VIRTUAL_EVENT using fts3 ( \
     254            xid_conference INTEGER  NOT NULL, \
     255            id INTEGER NOT NULL , \
     256            tag VARCHAR,title VARCHAR NOT NULL , \
     257            subtitle VARCHAR, \
     258            abstract VARCHAR, \
     259            description VARCHAR, \
     260            PRIMARY KEY (xid_conference,id))");
     261#endif
    259262
    260263        query.exec("CREATE TABLE EVENT_PERSON ( \
Note: See TracChangeset for help on using the changeset viewer.