1 | /* |
---|
2 | * Copyright (C) 2010 Ixonos Plc. |
---|
3 | * Copyright (C) 2011-2021 Philipp Spitzer, gregor herrmann, Stefan Stahl |
---|
4 | * |
---|
5 | * This file is part of ConfClerk. |
---|
6 | * |
---|
7 | * ConfClerk is free software: you can redistribute it and/or modify it |
---|
8 | * under the terms of the GNU General Public License as published by the Free |
---|
9 | * Software Foundation, either version 2 of the License, or (at your option) |
---|
10 | * any later version. |
---|
11 | * |
---|
12 | * ConfClerk is distributed in the hope that it will be useful, but |
---|
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
---|
14 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
15 | * more details. |
---|
16 | * |
---|
17 | * You should have received a copy of the GNU General Public License along with |
---|
18 | * ConfClerk. If not, see <http://www.gnu.org/licenses/>. |
---|
19 | */ |
---|
20 | |
---|
21 | #include "dayviewtabcontainer.h" |
---|
22 | |
---|
23 | DayViewTabContainer::DayViewTabContainer(QWidget *aParent): TabContainer(aParent) { |
---|
24 | } |
---|
25 | |
---|
26 | |
---|
27 | void DayViewTabContainer::expandTimeGroup(QTime time, int conferenceId) { |
---|
28 | EventModel* eventModel = static_cast<EventModel*>(treeView->model()); |
---|
29 | Conference conference = Conference::getById(conferenceId); |
---|
30 | |
---|
31 | // iterate over the time groups |
---|
32 | for (int g = 0; g != eventModel->rowCount(); ++g) { |
---|
33 | QModelIndex groupIdx = eventModel->index(g, 0); |
---|
34 | // iterate over the events in the group |
---|
35 | for (int e = 0; e != eventModel->rowCount(groupIdx); ++e) { |
---|
36 | QModelIndex eventIdx = eventModel->index(e, 0, groupIdx); |
---|
37 | int eventId = eventIdx.data().toInt(); |
---|
38 | Event event = Event::getById(eventId, conferenceId); |
---|
39 | QDateTime eventStart = event.start(); |
---|
40 | if (conference.hasDisplayTimeShift()) eventStart = eventStart.addSecs(conference.displayTimeShift() * 60); |
---|
41 | if (time < eventStart.time().addSecs(event.duration())) { // if time < end |
---|
42 | // expand this group |
---|
43 | treeView->expand(groupIdx); |
---|
44 | treeView->scrollTo(eventIdx, QAbstractItemView::PositionAtTop); |
---|
45 | return; |
---|
46 | } |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) { |
---|
53 | static_cast<EventModel*>(treeView->model())->loadEvents( aDate, aConferenceId ); |
---|
54 | } |
---|