source: src/gui/dayviewtabcontainer.cpp

Last change on this file was a59d5c4, checked in by gregor herrmann <gregor@…>, 5 months ago

Take display time shift into account when expanding a group in the day view tab.

  • Property mode set to 100644
File size: 2.2 KB
RevLine 
[ca90cb1]1/*
2 * Copyright (C) 2010 Ixonos Plc.
[ffb6be7]3 * Copyright (C) 2011-2021 Philipp Spitzer, gregor herrmann, Stefan Stahl
[ca90cb1]4 *
[6df32f2]5 * This file is part of ConfClerk.
[ca90cb1]6 *
[6df32f2]7 * ConfClerk is free software: you can redistribute it and/or modify it
[ca90cb1]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 *
[6df32f2]12 * ConfClerk is distributed in the hope that it will be useful, but
[ca90cb1]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
[6df32f2]18 * ConfClerk.  If not, see <http://www.gnu.org/licenses/>.
[ca90cb1]19 */
[07ae23a]20
21#include "dayviewtabcontainer.h"
22
[11d7ec5]23DayViewTabContainer::DayViewTabContainer(QWidget *aParent): TabContainer(aParent) {
[07ae23a]24}
25
[11d7ec5]26
27void DayViewTabContainer::expandTimeGroup(QTime time, int conferenceId) {
28    EventModel* eventModel = static_cast<EventModel*>(treeView->model());
[a59d5c4]29    Conference conference = Conference::getById(conferenceId);
[11d7ec5]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);
[a59d5c4]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
[11d7ec5]42                // expand this group
43                treeView->expand(groupIdx);
44                treeView->scrollTo(eventIdx, QAbstractItemView::PositionAtTop);
45                return;
46            }
47        }
48    }
[07ae23a]49}
50
[11d7ec5]51
52void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) {
[07ae23a]53    static_cast<EventModel*>(treeView->model())->loadEvents( aDate, aConferenceId );
54}
Note: See TracBrowser for help on using the repository browser.