Ignore:
Timestamp:
04/30/13 23:42:38 (9 years ago)
Author:
Philipp Spitzer <philipp@…>
Branches:
master, qt5
Children:
5130dc7
Parents:
83481c6
Message:

Now the dayChange time is taken into account. This fixes #43.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/eventmodel.cpp

    r83481c6 r41c4ceb  
    3030
    3131void EventModel::Group::setTitle(const QList<Event>& mEvents) {
    32     QTime startTime = mEvents.at(mFirstEventIndex).start().time();
    33     QTime endTime(0, 0);
     32    QDateTime startTime = mEvents.at(mFirstEventIndex).start();
     33    QDateTime endTime(startTime);
    3434    for (int i = mFirstEventIndex; i != mFirstEventIndex + mChildCount; ++i) {
    35         endTime = qMax(mEvents.at(i).start().time().addSecs(mEvents.at(i).duration()), endTime);
     35        endTime = qMax(mEvents.at(i).start().addSecs(mEvents.at(i).duration()), endTime);
    3636    }
    3737    mTitle = QString("%1 - %2").arg(startTime.toString("HH:mm")).arg(endTime.toString("HH:mm"));
     
    236236}
    237237
    238 void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
    239 {
    240     clearModel();
    241     // check for existence of the conference in the DB
    242     if(Conference::getAll().count())
    243     {
    244         mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
    245     }
     238
     239void EventModel::loadEvents(const QDate &aDate, int aConferenceId) {
     240    clearModel();
     241    mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
    246242    createTimeGroups();
    247243}
    248244
    249 void EventModel::loadFavEvents(const QDate &aDate, int aConferenceId)
    250 {
    251     clearModel();
    252     // check for existence of the conference in the DB
    253     if(Conference::getAll().count())
    254     {
    255         mEvents = Event::getFavByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
    256     }
     245
     246void EventModel::loadFavEvents(const QDate &aDate, int aConferenceId) {
     247    clearModel();
     248    mEvents = Event::getFavByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
    257249    createTimeGroups();
    258250}
    259251
    260 int EventModel::loadSearchResultEvents(const QDate &aDate, int aConferenceId)
    261 {
    262     clearModel();
    263     // check for existence of the conference in the DB
    264     if(Conference::getAll().count())
    265     {
    266         try{
    267             mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
    268         }
    269         catch( OrmException &e  ){
    270             qDebug() << "Event::getSearchResultByDate failed: " << e.text();
    271         }
    272         catch(...){
    273             qDebug() << "Event::getSearchResultByDate failed";
    274         }
    275 
     252
     253int EventModel::loadSearchResultEvents(const QDate &aDate, int aConferenceId) {
     254    clearModel();
     255    try {
     256        mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
     257    }
     258    catch( OrmException &e  ){
     259        qDebug() << "Event::getSearchResultByDate failed: " << e.text();
     260    }
     261    catch(...){
     262        qDebug() << "Event::getSearchResultByDate failed";
    276263    }
    277264
     
    281268}
    282269
    283 void EventModel::loadEventsByTrack(const QDate &aDate, int aConferenceId)
    284 {
    285     clearModel();
    286     if (Conference::getAll().count())
    287     {
    288         mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "xid_track, start, duration");
    289     }
     270
     271void EventModel::loadEventsByTrack(const QDate &aDate, int aConferenceId) {
     272    clearModel();
     273    mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "xid_track, start, duration");
    290274    createTrackGroups();
    291275}
    292276
    293 void EventModel::loadEventsByRoom(const QDate &aDate, int aConferenceId)
    294 {
    295     clearModel();
    296     if (Conference::getAll().count())
    297     {
    298         mEvents = Event::getByDateAndRoom(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
    299     }
     277
     278void EventModel::loadEventsByRoom(const QDate &aDate, int aConferenceId) {
     279    clearModel();
     280    mEvents = Event::getByDateAndRoom(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
    300281    createRoomGroups();
    301282}
     
    304285void EventModel::loadConflictEvents(int aEventId, int aConferenceId) {
    305286    clearModel();
    306     // check for existence of the conference in the DB
    307     if(Conference::getAll().count())
    308     {
    309         mEvents = Event::conflictEvents(aEventId, aConferenceId);
    310     }
     287    mEvents = Event::conflictEvents(aEventId, aConferenceId);
    311288    createTimeGroups();
    312289}
     290
    313291
    314292void EventModel::updateModel(int aEventId)
Note: See TracChangeset for help on using the changeset viewer.