- Timestamp:
- 05/03/12 22:36:20 (11 years ago)
- Branches:
- master, qt5
- Children:
- b686173
- Parents:
- a96e91c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mvc/eventmodel.cpp
ra96e91c r0b595d2 53 53 54 54 // Create the first time group. The events have to be sorted by start time at this point! 55 Q Time groupStartTime(mEvents.first().start().time().hour(), 0);56 Q Time groupEndTime = groupStartTime.addSecs(mEvents.first().duration());55 QDateTime groupStartDateTime(mEvents.first().start().date(), mEvents.first().start().time()); 56 QDateTime groupEndDateTime = groupStartDateTime.addSecs(mEvents.first().duration()); 57 57 mGroups << EventModel::Group("", 0); 58 58 int timeSpan = minTimeSpan; 59 59 60 60 for (int i = 0; i != mEvents.count(); ++i) { 61 Q Time eventStartTime = mEvents.at(i).start().time();62 Q Time eventEndTime = eventStartTime.addSecs(mEvents.at(i).duration());63 64 if (eventStart Time >= groupStartTime.addSecs(timeSpan)) {61 QDateTime eventStartDateTime (mEvents.at(i).start().date(), mEvents.at(i).start().time()); 62 QDateTime eventEndDateTime = eventStartDateTime.addSecs(mEvents.at(i).duration()); 63 64 if (eventStartDateTime >= groupStartDateTime.addSecs(timeSpan)) { 65 65 // a new group could be necessary 66 66 if (mGroups.last().mChildCount < minChildCount) { 67 67 // too few events in the group => no new group 68 68 // except a gap in time would occur that is longer than minTimeSpan 69 if (i > 0 && qMax(mEvents.at(i-1).start().time().addSecs(mEvents.at(i-1).duration()), groupEndTime).secsTo(eventStartTime) < minTimeSpan) { 69 QDateTime prevEventStartDateTime (mEvents.at(i).start().date(), mEvents.at(i).start().time()); 70 if (i > 0 && qMax(prevEventStartDateTime.addSecs(mEvents.at(i-1).duration()), groupEndDateTime).secsTo(eventStartDateTime) < minTimeSpan) { 70 71 timeSpan += minTimeSpan; 71 72 --i; … … 76 77 // a new group is necessary 77 78 mGroups.last().setTitle(mEvents); 78 groupStart Time = groupStartTime.addSecs(timeSpan);79 groupEnd Time = groupStartTime.addSecs(mEvents.at(i).duration());79 groupStartDateTime = groupStartDateTime.addSecs(timeSpan); 80 groupEndDateTime = groupStartDateTime.addSecs(mEvents.at(i).duration()); 80 81 mGroups << EventModel::Group("", i); 81 82 timeSpan = minTimeSpan; … … 85 86 mParents[mEvents.at(i).id()] = mGroups.count() - 1; 86 87 mGroups.last().mChildCount += 1; 87 groupEnd Time = qMax(eventEndTime, groupEndTime);88 groupEndDateTime = qMax(eventEndDateTime, groupEndDateTime); 88 89 } 89 90
Note: See TracChangeset
for help on using the changeset viewer.