+int EventModel::loadSearchResultEvents(const QDate &aDate, int aConferenceId)
+{
+ clearModel();
+ // check for existence of the conference in the DB
+ if(Conference::getAll().count())
+ {
+ try{
+ mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
+ }
+ catch( OrmException &e ){
+ qDebug() << "Event::getSearchResultByDate failed: " << e.text();
+ }
+ catch(...){
+ qDebug() << "Event::getSearchResultByDate failed";
+ }
+
+ }
+
+ createTimeGroups();
+
+ return mEvents.count();
+}
+
+void EventModel::loadEventsByTrack(const QDate &aDate, int aConferenceId)
+{
+ clearModel();
+ if (Conference::getAll().count())
+ {
+ mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "xid_track, start, duration");
+ }
+ createTrackGroups();
+}
+
+void EventModel::loadEventsByRoom(const QDate &aDate, int aConferenceId)
+{
+ clearModel();
+ if (Conference::getAll().count())
+ {
+ mEvents = Event::getByDateAndRoom(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
+ }
+ createRoomGroups();
+}
+
+
+void EventModel::loadConflictEvents(int aEventId, int aConferenceId) {
+ clearModel();
+ // check for existence of the conference in the DB
+ if(Conference::getAll().count())
+ {
+ mEvents = Event::conflictEvents(aEventId, aConferenceId);
+ }
+ createTimeGroups();
+}
+
+void EventModel::updateModel(int aEventId)
+{
+ for(int i=0; i<mEvents.count(); i++)
+ {
+ if(mEvents[i].id() == aEventId)
+ mEvents[i] = Event::getById(aEventId,Conference::activeConference());
+ }
+
+ // find the ModelIndex for given aEventId
+ for(int i=0; i<mGroups.count(); i++)
+ {
+ QModelIndex groupIndex = index(i,0,QModelIndex());
+ for(int j=0; j<mGroups[i].mChildCount; j++)
+ {
+ QModelIndex eventIndex = index(j,0,groupIndex);
+ if(static_cast<Event*>(eventIndex.internalPointer())->id() == aEventId)
+ {
+ emit(dataChanged(groupIndex,groupIndex));
+ emit(dataChanged(eventIndex,eventIndex));
+ }
+ }
+ }
+}
+