/*
* Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011 Philipp Spitzer, gregor herrmann
+ * Copyright (C) 2011-2013 Philipp Spitzer, gregor herrmann, Stefan Stahl
*
* This file is part of ConfClerk.
*
#include "dayviewtabcontainer.h"
-DayViewTabContainer::DayViewTabContainer(QWidget *aParent) : TabContainer( aParent )
-{
+DayViewTabContainer::DayViewTabContainer(QWidget *aParent): TabContainer(aParent) {
}
-DayViewTabContainer::~DayViewTabContainer()
-{
+
+void DayViewTabContainer::expandTimeGroup(QTime time, int conferenceId) {
+ EventModel* eventModel = static_cast<EventModel*>(treeView->model());
+
+ // iterate over the time groups
+ for (int g = 0; g != eventModel->rowCount(); ++g) {
+ QModelIndex groupIdx = eventModel->index(g, 0);
+ // iterate over the events in the group
+ for (int e = 0; e != eventModel->rowCount(groupIdx); ++e) {
+ QModelIndex eventIdx = eventModel->index(e, 0, groupIdx);
+ int eventId = eventIdx.data().toInt();
+ Event event = Event::getById(eventId, conferenceId);
+ if (time < event.start().time().addSecs(event.duration())) { // if time < end
+ // expand this group
+ treeView->expand(groupIdx);
+ treeView->scrollTo(eventIdx, QAbstractItemView::PositionAtTop);
+ return;
+ }
+ }
+ }
}
-void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId )
-{
+
+void DayViewTabContainer::loadEvents( const QDate &aDate, const int aConferenceId ) {
static_cast<EventModel*>(treeView->model())->loadEvents( aDate, aConferenceId );
}