Adjust shown event time when displayTimeShift is set.
[debian/confclerk.git] / src / gui / daynavigatorwidget.cpp
index 0fdfe97ff74f1efe5ec37e98750918dee6c3ac3c..82b34438156d8d869e4842228bd819f10dfc3531 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <QPainter>
 #include <QLabel>
+#include <conference.h>
+#include <application.h>
 
 
 DayNavigatorWidget::DayNavigatorWidget(QWidget *aParent): QWidget(aParent) {
@@ -107,8 +109,22 @@ void DayNavigatorWidget::nextDayButtonClicked() {
 
 void DayNavigatorWidget::paintEvent(QPaintEvent *aEvent) {
     Q_UNUSED(aEvent);
-
-    QString selectedDateStr = mCurDate.isValid() ? mCurDate.toString("dddd\nyyyy-MM-dd") : tr("No date");
+    QString selectedDateStr;
+    if (mCurDate.isValid()) {
+        selectedDateStr = mCurDate.toString("dddd\nyyyy-MM-dd");
+        bool hasConference = ((Application*) qApp)->hasActiveConference();
+        if (hasConference) {
+            Conference& conference = ((Application*) qApp)->activeConference();
+            if (conference.hasDisplayTimeShift() && conference.displayTimeShift() != 0) {
+                QTime shift(0, 0);
+                bool minus = conference.displayTimeShift() < 0;
+                shift = shift.addSecs(conference.displayTimeShift() * 60 * (minus ? -1 : 1));
+                selectedDateStr += " (" + (minus ? QString("-") : "+") + shift.toString("HH:mm") + ")";
+            }
+        }
+    } else {
+        selectedDateStr = tr("No date");
+    }
     QPainter painter(this);
     painter.save();