From 15cb77fe45dae0eca3be00f4018f2dc39805a198 Mon Sep 17 00:00:00 2001
From: Mark Watkins <jedimark@users.sourceforge.net>
Date: Sun, 20 Jul 2014 14:47:32 +1000
Subject: [PATCH] Position User flagging at end of event to match ResMed
 behaviour

---
 sleepyhead/Graphs/gLineOverlay.cpp | 6 +++++-
 sleepyhead/SleepLib/calcs.cpp      | 2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/sleepyhead/Graphs/gLineOverlay.cpp b/sleepyhead/Graphs/gLineOverlay.cpp
index 72de500e..90004ef6 100644
--- a/sleepyhead/Graphs/gLineOverlay.cpp
+++ b/sleepyhead/Graphs/gLineOverlay.cpp
@@ -239,7 +239,11 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
                         painter.drawLine(x1, z, x1, z - 12);
                     }
 
-                    if (xx < (1800000)) {
+                    if (xx < 300000) {
+                        QString lab = schema::channel[m_code].fullname();
+                        GetTextExtent(lab, x, y);
+                        w.renderText(lab, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()));
+                    } else if (xx < (3600000)) {
                         if (!hover) {
                             GetTextExtent(m_label, x, y);
                             w.renderText(m_label, x1 - (x / 2)+2, top - y + (3 * w.printScaleY()));
diff --git a/sleepyhead/SleepLib/calcs.cpp b/sleepyhead/SleepLib/calcs.cpp
index 96f2509f..d117c686 100644
--- a/sleepyhead/SleepLib/calcs.cpp
+++ b/sleepyhead/SleepLib/calcs.cpp
@@ -759,7 +759,7 @@ void FlowParser::flagEvents()
                     uf1 = m_session->AddEventList(CPAP_UserFlag1, EVL_Event);
                 }
 
-                uf1->AddEvent(et - len / 2, dur);
+                uf1->AddEvent(et, dur);
             }
         }
     }