diff --git a/Graphs/gSummaryChart.cpp b/Graphs/gSummaryChart.cpp index c6b94e5d..ece75192 100644 --- a/Graphs/gSummaryChart.cpp +++ b/Graphs/gSummaryChart.cpp @@ -65,7 +65,7 @@ void SummaryChart::SetDay(Day * nullday) for (int i=0;imachine_type()!=m_machinetype) continue; - if (type==ST_HOURS || day->channelExists(code) || day->settingExists(code)) { // too many lookups happening here.. stop the crap.. + if (type==ST_HOURS || type==ST_SESSIONS || day->channelHasData(code) || day->settingExists(code)) { // too many lookups happening here.. stop the crap.. m_days[dn]=day; switch(m_type[j]) { case ST_AVG: tmp=day->avg(code); break; @@ -78,6 +78,7 @@ void SummaryChart::SetDay(Day * nullday) case ST_CPH: tmp=day->cph(code); break; case ST_SPH: tmp=day->sph(code); break; case ST_HOURS: tmp=day->hours(); break; + case ST_SESSIONS: tmp=day->size(); break; case ST_SETMIN: tmp=day->settings_min(code); break; case ST_SETMAX: tmp=day->settings_max(code); break; case ST_SETAVG: tmp=day->settings_avg(code); break; @@ -352,6 +353,8 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height) case ST_CPH: a+=""; break; case ST_SPH: a+="%"; break; case ST_HOURS: a+="Hours"; break; + case ST_SESSIONS: a+="Sessions"; break; + default: break; } @@ -403,6 +406,7 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height) w.renderText(a,left,top-3); } + bool SummaryChart::mouseMoveEvent(QMouseEvent *event) { int x=event->x()-l_left; @@ -472,13 +476,19 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) case ST_CPH: a=""; break; case ST_SPH: a="%"; break; case ST_HOURS: a="Hours"; break; + case ST_SESSIONS: a="Sessions"; break; default: break; } - if (day && (day->channelExists(m_codes[i]) || day->settingExists(m_codes[i]))) { - schema::Channel & chan=schema::channel[m_codes[i]]; - val=QString::number(d.value()[i+1],'f',2); - z+="\r\n"+chan.label()+" "+a+"="+val; + if (m_type[i]==ST_SESSIONS) { + val=QString::number(d.value()[i+1],'f',0); + z+="\r\n"+a+"="+val; + } else { + if (day && (day->channelExists(m_codes[i]) || day->settingExists(m_codes[i]))) { + schema::Channel & chan=schema::channel[m_codes[i]]; + val=QString::number(d.value()[i+1],'f',2); + z+="\r\n"+chan.label()+" "+a+"="+val; + } } } diff --git a/SleepLib/session.cpp b/SleepLib/session.cpp index 3aa078a0..f2a0b4c3 100644 --- a/SleepLib/session.cpp +++ b/SleepLib/session.cpp @@ -549,6 +549,7 @@ bool Session::channelExists(ChannelID id) QHash::iterator q=m_cnt.find(id); if (q==m_cnt.end()) return false; + if (q.value()==0) return false; } return true; } diff --git a/SleepLib/session.h b/SleepLib/session.h index f80d60a6..2492ee9d 100644 --- a/SleepLib/session.h +++ b/SleepLib/session.h @@ -19,7 +19,7 @@ class Machine; const quint32 magic=0xC73216AB; -enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_CPH, ST_SPH, ST_FIRST, ST_LAST, ST_HOURS, ST_SETMIN, ST_SETAVG, ST_SETMAX, ST_SETWAVG, ST_SETSUM }; +enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_CPH, ST_SPH, ST_FIRST, ST_LAST, ST_HOURS, ST_SESSIONS, ST_SETMIN, ST_SETAVG, ST_SETMAX, ST_SETWAVG, ST_SETSUM }; class Session { diff --git a/overview.cpp b/overview.cpp index 68ddc8ca..83e69e2e 100644 --- a/overview.cpp +++ b/overview.cpp @@ -54,6 +54,7 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : PR=new gGraph(GraphView,"Pressure",default_height,0); SET=new gGraph(GraphView,"Settings",default_height,0); LK=new gGraph(GraphView,"Leaks",default_height,0); + SES=new gGraph(GraphView,"Sessions",default_height,0); uc=new SummaryChart("Hours",GT_BAR); uc->addSlice("",QColor("green"),ST_HOURS); @@ -64,6 +65,16 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : UC->AddLayer(uc); UC->AddLayer(new gXGrid()); + ses=new SummaryChart("Sessions",GT_LINE); + ses->addSlice("",QColor("blue"),ST_SESSIONS); + SES->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); + gx=new gXAxis(); + gx->setUtcFix(true); + SES->AddLayer(gx,LayerBottom,0,gXAxis::Margin); + SES->AddLayer(ses); + SES->AddLayer(new gXGrid()); + + bc=new SummaryChart("AHI",GT_BAR); bc->addSlice(CPAP_Hypopnea,QColor("blue"),ST_CPH); @@ -260,6 +271,7 @@ QString Overview::GetHTML() pr->deselect(); lk->deselect(); npb->deselect(); + ses->deselect(); report->ReloadGraphs(); QString reportname="overview"; diff --git a/overview.h b/overview.h index 54e04a1e..5d5a00fc 100644 --- a/overview.h +++ b/overview.h @@ -34,8 +34,8 @@ public: void RedrawGraphs(); - gGraph *AHI,*UC,*PR,*LK,*NPB,*SET; - SummaryChart *bc,*uc,*pr,*lk,*npb,*set; + gGraph *AHI,*UC,*PR,*LK,*NPB,*SET,*SES; + SummaryChart *bc,*uc,*pr,*lk,*npb,*set,*ses; public slots: void on_printButton_clicked();