statusBar()->showMessage(tr("Ready"));
connect(dayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateDayView(const QDate &)));
-
+ connect(activityDayNavigator, SIGNAL(dateChanged(const QDate &)), SLOT(updateActivitiesDayView(const QDate &)));
+ connect(tabWidget, SIGNAL(currentChanged(int)), SLOT(updateView(int)));
// DAY EVENTS View
dayTreeView->setHeaderHidden(true);
{
int confId = 1;
// 'dayNavigator' emits signal 'dateChanged' after setting valid START:END dates
- dayNavigator->setDates(Conference::getById(confId).start(),Conference::getById(confId).end());
+ dayNavigator->setDates(Conference::getById(confId).start(), Conference::getById(confId).end());
}
}
updateFavView();
updateDayView(Conference::getById(confId).start());
}
+
+void MainWindow::updateActivitiesDayView(const QDate &aDate)
+{
+ int confId = 1;
+ static_cast<EventModel*>(activityDayTreeView->model())->loadEventsByActivities(aDate,confId);
+ activityDayTreeView->reset();
+ activityDayNavigator->show();
+}
+
+void MainWindow::updateView(int tabIndex)
+{
+ //TODO korinpa: skraslit ! aj pre ine taby
+ qDebug() << "updateView index: " << tabIndex;
+ if (tabIndex == 2)
+ {
+ QDate date = activityDayNavigator->getCurrentDate();
+ updateActivitiesDayView(date);
+ }
+}
+
<attribute name="title" >
<string>Activities</string>
</attribute>
+ <widget class="QWidget" name="verticalLayoutWidget" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>501</width>
+ <height>231</height>
+ </rect>
+ </property>
+ <layout class="QVBoxLayout" name="activitiesVerticalLayout" >
+ <item>
+ <widget class="DayNavigatorWidget" native="1" name="activityDayNavigator" />
+ </item>
+ <item>
+ <widget class="TreeView" name="activityDayTreeView" >
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</widget>
<widget class="QWidget" name="searchTab" >
<attribute name="title" >
<x>0</x>
<y>0</y>
<width>534</width>
- <height>26</height>
+ <height>40</height>
</rect>
</property>
<widget class="QMenu" name="menuFile" >
mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
}
+void EventModel::createActivityGroups() {
+ mGroups.clear();
+ mParents.clear();
+ if (mEvents.empty())
+ {
+ return;
+ }
+ int activityId = mEvents.first().activityId();
+ //TODO korinpa: get activity name
+ mGroups << EventModel::Group(QString("activity %1").arg(activityId), 0);
+ int nextActivityId = activityId;
+
+ for (int i=0; i<mEvents.count(); i++)
+ {
+ activityId = mEvents.at(i).activityId();
+ if (nextActivityId != activityId)
+ {
+ mGroups.last().mChildCount = i - mGroups.last().mFirstEventIndex;
+ mGroups << EventModel::Group(QString("activity %1").arg(activityId), 0);
+ int nextActivityId = activityId;
+ }
+ // add parent-child relation
+ mParents[mEvents.at(i).id()] = mGroups.count() - 1;
+ }
+ mGroups.last().mChildCount = mEvents.count() - mGroups.last().mFirstEventIndex;
+}
+
QVariant EventModel::data(const QModelIndex& index, int role) const
{
if (index.isValid() && role == Qt::DisplayRole)
return 0;
}
-void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
+void EventModel::clearModel()
{
- for(int i=0; i<mGroups.count(); i++)
- {
- QModelIndex idx = index(i,0);
+/*
+ for(int i = 0;i < mGroups.count();i++){
+ QModelIndex idx = index(i, 0);
Group group = mGroups[i];
- beginRemoveRows(idx,0,group.mChildCount-1);
- removeRows(0,group.mChildCount,idx);
+ beginRemoveRows(idx, 0, group.mChildCount - 1);
+ bool ok = removeRows(0, group.mChildCount, idx);
endRemoveRows();
//qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
}
-
+*/
+ mGroups.clear();
mEvents.clear();
+}
+void EventModel::loadEvents(const QDate &aDate, int aConferenceId)
+{
+ clearModel();
// check for existence of the conference in the DB
if(Conference::getAll().count())
{
void EventModel::loadFavEvents(const QDate &aDate, int aConferenceId)
{
- for(int i=0; i<mGroups.count(); i++)
- {
- QModelIndex idx = index(i,0);
- Group group = mGroups[i];
- beginRemoveRows(idx,0,group.mChildCount-1);
- removeRows(0,group.mChildCount,idx);
- endRemoveRows();
- //qDebug() << "removing " << group.mChildCount << " events from group:" << i << idx.data() << ":" << ok;
- }
-
- mEvents.clear();
-
+ clearModel();
// check for existence of the conference in the DB
if(Conference::getAll().count())
{
createTimeGroups();
}
+void EventModel::loadEventsByActivities(const QDate &aDate, int aConferenceId)
+{
+ clearModel();
+ if(Conference::getAll().count())
+ {
+ qDebug() << "Loading Conference Data (by Activities): [" << Conference::getById(aConferenceId).title() << "] " << aDate;
+ mEvents = Event::getByDate(QDate(aDate.year(), aDate.month(), aDate.day()), aConferenceId);
+ }
+ createActivityGroups();
+}
+
void EventModel::emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight)
{
emit(dataChanged(aTopLeft,aBottomRight));
int rowCount ( const QModelIndex & parent = QModelIndex() ) const;
void loadEvents(const QDate &aDate, int aConferenceId); // loads Events from the DB
void loadFavEvents(const QDate &aDate, int aConferenceId); // loads Favourite events from the DB
-
+ void loadEventsByActivities(const QDate &aDate, int aConferenceId); // loads Events grouped by Activities from the DB
// a method to force 'EventModel' emit signal 'dataChanged()'
// a 'view', eg. 'TreeView' listens for this signal and redraws changed items(indexes)
void emitDataChangedSignal(const QModelIndex &aTopLeft, const QModelIndex &aBottomRight);
private:
void createTimeGroups();
+ void createActivityGroups();
+ void clearModel();
private:
QList<Event> mEvents;