/*
* Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ * Copyright (C) 2011-2012 Philipp Spitzer, gregor herrmann
*
* This file is part of ConfClerk.
*
mParents.clear();
if (mEvents.empty()) return;
- const int minTimeSpan = 3600; // one hour
- const int minChildCount = 3; // minimum number of events in one group
+ const int minTimeSpan = 3600; // one hour // minimum duration of a group
+ const int minChildCount = 3; // minimum number of events in one group
// Create the first time group. The events have to be sorted by start time at this point!
- QTime groupStartTime(mEvents.first().start().time().hour(), 0);
- QTime groupEndTime = groupStartTime.addSecs(mEvents.first().duration());
+ // Remarks for the following non-comment line:
+ // * As it is right now it could be written as
+ // QDateTime groupStartDateTime = mEvents.first().start();
+ // * Before r1444 the minutes were set to zero so that the time groups started at
+ // whole hours.
+
+ // QDateTime groupStartDateTime(mEvents.first().start().date(), QTime(mEvents.first().start().time().hour(), 0));
+ QDateTime groupStartDateTime = mEvents.first().start();
+ QDateTime groupEndDateTime = groupStartDateTime.addSecs(mEvents.first().duration());
mGroups << EventModel::Group("", 0);
int timeSpan = minTimeSpan;
for (int i = 0; i != mEvents.count(); ++i) {
- QTime eventStartTime = mEvents.at(i).start().time();
- QTime eventEndTime = eventStartTime.addSecs(mEvents.at(i).duration());
+ QDateTime eventStartDateTime = mEvents.at(i).start();
+ QDateTime eventEndDateTime = eventStartDateTime.addSecs(mEvents.at(i).duration());
- if (eventStartTime >= groupStartTime.addSecs(timeSpan)) {
+ if (eventStartDateTime >= groupStartDateTime.addSecs(timeSpan)) {
// a new group could be necessary
if (mGroups.last().mChildCount < minChildCount) {
// too few events in the group => no new group
// except a gap in time would occur that is longer than minTimeSpan
- if (i > 0 && qMax(mEvents.at(i-1).start().time().addSecs(mEvents.at(i-1).duration()), groupEndTime).secsTo(eventStartTime) < minTimeSpan) {
+ QDateTime prevEventStartDateTime = mEvents.at(i).start();
+ if (i > 0 && qMax(prevEventStartDateTime.addSecs(mEvents.at(i-1).duration()), groupEndDateTime).secsTo(eventStartDateTime) < minTimeSpan) {
timeSpan += minTimeSpan;
--i;
continue; // repeat with the same event
// a new group is necessary
mGroups.last().setTitle(mEvents);
- groupStartTime = groupStartTime.addSecs(timeSpan);
- groupEndTime = groupStartTime.addSecs(mEvents.at(i).duration());
+ groupStartDateTime = groupStartDateTime.addSecs(timeSpan);
+ groupEndDateTime = groupStartDateTime.addSecs(mEvents.at(i).duration());
mGroups << EventModel::Group("", i);
timeSpan = minTimeSpan;
}
// insert event into current group
mParents[mEvents.at(i).id()] = mGroups.count() - 1;
mGroups.last().mChildCount += 1;
- groupEndTime = qMax(eventEndTime, groupEndTime);
+ groupEndDateTime = qMax(eventEndDateTime, groupEndDateTime);
}
// the last group needs a title as well
// check for existence of the conference in the DB
if(Conference::getAll().count())
{
- mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start");
+ mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
}
createTimeGroups();
}
if(Conference::getAll().count())
{
try{
- mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start");
+ mEvents = Event::getSearchResultByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "start, duration");
}
catch( OrmException &e ){
qDebug() << "Event::getSearchResultByDate failed: " << e.text();
clearModel();
if (Conference::getAll().count())
{
- mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "xid_track, start");
+ mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId, "xid_track, start, duration");
}
createTrackGroups();
}
createRoomGroups();
}
-void EventModel::loadNowEvents(int aConferenceId)
-{
- clearModel();
- // check for existence of the conference in the DB
- if(Conference::getAll().count())
- {
- mEvents = Event::nowEvents(aConferenceId, "start");
- }
- createTimeGroups();
-}
-void EventModel::loadConflictEvents(int aEventId, int aConferenceId)
-{
+void EventModel::loadConflictEvents(int aEventId, int aConferenceId) {
clearModel();
// check for existence of the conference in the DB
if(Conference::getAll().count())