]> ToastFreeware Gitweb - toast/confclerk.git/blobdiff - src/mvc/eventmodel.cpp
Adjust shown event time when displayTimeShift is set.
[toast/confclerk.git] / src / mvc / eventmodel.cpp
index 139d3301e1642d3fdbce0991325fbe164dcd8c1e..ac131a4099b52d6d023d8b690a7593d6e2f0cd57 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Ixonos Plc.
- * Copyright (C) 2011-2013 Philipp Spitzer, gregor herrmann, Stefan Stahl
+ * Copyright (C) 2011-2017 Philipp Spitzer, gregor herrmann, Stefan Stahl
  *
  * This file is part of ConfClerk.
  *
@@ -22,6 +22,8 @@
 #include "track.h"
 #include "room.h"
 
+#include <application.h>
+
 const QString EventModel::COMMA_SEPARATOR = ", ";
 
 EventModel::EventModel()
@@ -34,7 +36,10 @@ void EventModel::Group::setTitle(const QList<Event>& mEvents) {
     for (int i = mFirstEventIndex; i != mFirstEventIndex + mChildCount; ++i) {
         endTime = qMax(mEvents.at(i).start().addSecs(mEvents.at(i).duration()), endTime);
     }
-    mTitle = QString("%1 - %2").arg(startTime.toString("HH:mm")).arg(endTime.toString("HH:mm"));
+    Conference& conference = ((Application*) qApp)->activeConference();
+    QTime s = conference.shiftTime(startTime.time());
+    QTime e = conference.shiftTime(endTime.time());
+    mTitle = QString("%1 - %2").arg(s.toString("HH:mm")).arg(e.toString("HH:mm"));
 }
 
 
@@ -44,6 +49,8 @@ void EventModel::Group::setTitle(const QList<Event>& mEvents) {
 // multiple of one hour.
 void EventModel::createTimeGroups()
 {
+    beginResetModel();
+
     mGroups.clear();
     mParents.clear();
     if (mEvents.empty()) return;
@@ -90,7 +97,7 @@ void EventModel::createTimeGroups()
     // the last group needs a title as well
     mGroups.last().setTitle(mEvents);
 
-    reset();
+    endResetModel();
 }
 
 void EventModel::createTrackGroups() {
@@ -174,7 +181,7 @@ QModelIndex EventModel::index(int row, int column, const QModelIndex& parent) co
 
     if (!parent.isValid())
     {
-        return createIndex(row, column, 0);
+        return createIndex(row, column);
     }
     else if (parent.internalId() == 0)
     {
@@ -199,7 +206,7 @@ QModelIndex EventModel::parent(const QModelIndex & index) const
 
         Event * event = static_cast<Event*>(index.internalPointer());
 
-        return createIndex(mParents[event->id()], 0, 0);
+        return createIndex(mParents[event->id()], 0);
     }
 
     return QModelIndex();
@@ -228,11 +235,11 @@ int EventModel::rowCount (const QModelIndex & parent) const
 
 void EventModel::clearModel()
 {
+    beginResetModel();
     mGroups.clear();
     mEvents.clear();
     mParents.clear();
-
-    reset();
+    endResetModel();
 }