From f0f6232c8aca61f51acb3c417b059fd4c4b09dbe Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Sun, 3 Jul 2011 02:07:38 +1000 Subject: [PATCH] fixed hours() related hang --- Graphs/gYAxis.cpp | 4 +++- Graphs/graphdata_custom.cpp | 7 ++++++- SleepLib/day.h | 2 +- daily.cpp | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Graphs/gYAxis.cpp b/Graphs/gYAxis.cpp index a1067cda..0c8e5b2b 100644 --- a/Graphs/gYAxis.cpp +++ b/Graphs/gYAxis.cpp @@ -68,7 +68,9 @@ void gYAxis::Plot(gGraphWindow &w,float scrx,float scry) glColor4ub(linecol1.red(),linecol1.green(),linecol1.blue(),linecol1.alpha()); glLineWidth(1); - + if (min_ytick>=1000000) { + min_ytick=100; + } for (double i=miny+(min_ytick/2.0); isummary_sum(CPAP_Obstructive) + day->summary_sum(CPAP_Hypopnea) + day->summary_sum(CPAP_ClearAirway)) / day->hours(); + double h=day->hours(); + double ahi=(day->summary_sum(CPAP_Obstructive) + day->summary_sum(CPAP_Hypopnea) + day->summary_sum(CPAP_ClearAirway)) / h; + if (ahi>1000) { + ahi=999; + } + return ahi; } void HistoryData::Reload(Day *day) diff --git a/SleepLib/day.h b/SleepLib/day.h index e9af086a..ed304219 100644 --- a/SleepLib/day.h +++ b/SleepLib/day.h @@ -46,7 +46,7 @@ public: qint64 last() { return d_last; }; qint64 total_time(); // in milliseconds - float hours() { return total_time()/3600000.0; }; + double hours() { return double(total_time())/3600000.0; }; Session *operator [](int i) { return sessions[i]; }; diff --git a/daily.cpp b/daily.cpp index 8c76768c..097d85a2 100644 --- a/daily.cpp +++ b/daily.cpp @@ -554,7 +554,7 @@ void Daily::Load(QDate date) QDateTime date=QDateTime::fromMSecsSinceEpoch(cpap->first()); QDateTime date2=QDateTime::fromMSecsSinceEpoch(cpap->last()); - html+=""+date.toString(Qt::SystemLocaleShortDate)+""+date.toString("HH:mm")+""+date2.toString("HH:mm")+""+a.sprintf("%02i:%02i",tt/3600,tt%60)+"\n"; + html+=""+date.date().toString(Qt::SystemLocaleShortDate)+""+date.toString("HH:mm")+""+date2.toString("HH:mm")+""+a.sprintf("%02i:%02i",tt/3600,tt%60)+"\n"; html+="
\n"; QString cs;