From 039b7d2f9affc8544a021b1de66ccd4ed3c8e1a0 Mon Sep 17 00:00:00 2001
From: Mark Watkins <jedimark@users.sourceforge.net>
Date: Mon, 8 Aug 2011 06:51:11 +1000
Subject: [PATCH] Something prettier than an empty Event Breakdown :)

---
 Resources.qrc |  1 +
 daily.cpp     | 26 +++++++++++++++-----------
 oximetry.cpp  |  7 +------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/Resources.qrc b/Resources.qrc
index 6ab2e34d..09eb9209 100644
--- a/Resources.qrc
+++ b/Resources.qrc
@@ -14,5 +14,6 @@
         <file>icons/refresh.png</file>
         <file>docs/usage.html</file>
         <file>icons/oximeter.png</file>
+        <file>docs/0.0.gif</file>
     </qresource>
 </RCC>
diff --git a/daily.cpp b/daily.cpp
index 81f3af6e..2844195d 100644
--- a/daily.cpp
+++ b/daily.cpp
@@ -724,9 +724,9 @@ void Daily::Load(QDate date)
         float vsi=cpap->count(CPAP_VSnore)/cpap->hours();
         float fli=cpap->count(CPAP_FlowLimit)/cpap->hours();
 
-        float p90=cpap->p90(CPAP_Pressure);
-        eap90=cpap->p90(CPAP_EPAP);
-        iap90=cpap->p90(CPAP_IPAP);
+        //float p90=cpap->p90(CPAP_Pressure);
+        //eap90=cpap->p90(CPAP_EPAP);
+        //iap90=cpap->p90(CPAP_IPAP);
         QString submodel=tr("Unknown Model");
 
         //html+="<tr><td colspan=4 align=center><i>"+tr("Machine Information")+"</i></td></tr>\n";
@@ -781,14 +781,18 @@ void Daily::Load(QDate date)
         // ^^ Scratch that.. pie now includes text..
 
         if (pref["EnableGraphSnapshots"].toBool()) {  // AHI Pie Chart
-            html+="</tr>\n<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n";
-            G_AHI->setFixedSize(gwwidth,120);
-            QPixmap pixmap=G_AHI->renderPixmap(gwwidth,120,false); //gwwidth,gwheight,false);
-            QByteArray byteArray;
-            QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
-            buffer.open(QIODevice::WriteOnly);
-            pixmap.save(&buffer, "PNG");
-            html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
+            if (ahi+rei+fli>0) {
+                html+="</tr>\n<tr><td colspan=4 align=center><i>"+tr("Event Breakdown")+"</i></td></tr>\n";
+                G_AHI->setFixedSize(gwwidth,120);
+                QPixmap pixmap=G_AHI->renderPixmap(gwwidth,120,false); //gwwidth,gwheight,false);
+                QByteArray byteArray;
+                QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray
+                buffer.open(QIODevice::WriteOnly);
+                pixmap.save(&buffer, "PNG");
+                html += "<tr><td colspan=4 align=center><img src=\"data:image/png;base64," + byteArray.toBase64() + "\"></td></tr>\n";
+            } else {
+                html += "<tr><td colspan=4 align=center><img src=\"qrc:/docs/0.0.gif\"></td></tr>\n";
+            }
         }
     }
     html+="</table>"
diff --git a/oximetry.cpp b/oximetry.cpp
index f68588af..9b3440a1 100644
--- a/oximetry.cpp
+++ b/oximetry.cpp
@@ -265,7 +265,7 @@ void Oximetry::on_RunButton_toggled(bool checked)
             sess->SetSessionID(starttime/1000L);
 
             sess->setMin(OXI_Pulse,ev_pulse->min());
-            sess->setMax(OXI_Pulse,ev_pulse->min());
+            sess->setMax(OXI_Pulse,ev_pulse->max());
             sess->setFirst(OXI_Pulse,ev_pulse->first());
             sess->setLast(OXI_Pulse,ev_pulse->last());
             sess->avg(OXI_Pulse);
@@ -284,11 +284,6 @@ void Oximetry::on_RunButton_toggled(bool checked)
             //sess->min(OXI_SPO2);
             //sess->max(OXI_SPO2);
 
-            sess->setMin(OXI_SPO2,ev_spo2->min());
-            sess->setMax(OXI_SPO2,ev_spo2->max());
-            sess->setFirst(OXI_SPO2,ev_spo2->first());
-            sess->setLast(OXI_SPO2,ev_spo2->last());
-
             //sess->min(OXI_Plethysomogram);
             //sess->max(OXI_Plethysomogram);
             sess->avg(OXI_Plethysomogram);