From add1a51db61ae25b2da7c88ec465a03462b7d5c4 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Tue, 13 Sep 2011 13:38:02 +1000 Subject: [PATCH] Show time rather than decimal hours in Usage popup --- Graphs/gBarChart.cpp | 22 ++++++++++++++++------ Graphs/gXAxis.cpp | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Graphs/gBarChart.cpp b/Graphs/gBarChart.cpp index 21673b33..17ef2ba3 100644 --- a/Graphs/gBarChart.cpp +++ b/Graphs/gBarChart.cpp @@ -235,9 +235,9 @@ void SummaryChart::paint(gGraph & w,int left, int top, int width, int height) if (d!=m_values.end()) { day=m_days[zd]; - float x1=px; + int x1=px; //x1-=(barw/2.0); - float x2=px+barw; + int x2=px+barw; if (x1left+width) x2=left+width; @@ -369,6 +369,7 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) mx=mx+l_offset;//-86400000L; int zd=mx/86400000L; + Day * day; //if (hl_day!=zd) // This line is an optimization { @@ -376,19 +377,28 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) QHash >::iterator d=m_values.find(hl_day); if (d!=m_values.end()) { + day=m_days[zd]; x+=gYAxis::Margin+gGraphView::titleWidth; //graph->m_marginleft+ int y=event->y()+rtop-10; QDateTime dt=QDateTime::fromTime_t(hl_day*86400); // Day * day=m_days[hl_day]; - EventDataType val; + //EventDataType val; + QString val; if (m_graphtype==GT_BAR) { - val=d.value()[0]; + if (m_type[0]==ST_HOURS) { + int t=d.value()[0]*3600.0; + int h=t/3600; + int m=(t / 60) % 60; + int s=t % 60; + val.sprintf("%02i:%02i:%02i",h,m,s); + } else val=QString::number(d.value()[0]); } else { - val=d.value()[1]; + val=QString::number(d.value()[1]); } - QString z=dt.date().toString(Qt::SystemLocaleShortDate)+"\n"+m_label+"="+QString::number(val,'f',2);//+"\nAHI="+QString::number(day->cph(CPAP_AHI)); + + QString z=dt.date().toString(Qt::SystemLocaleShortDate)+"\n"+m_label+"="+val;//+"\nAHI="+QString::number(day->cph(CPAP_AHI)); graph->ToolTip(z,x,y,1500); return true; } diff --git a/Graphs/gXAxis.cpp b/Graphs/gXAxis.cpp index 8d308367..ab3dce14 100644 --- a/Graphs/gXAxis.cpp +++ b/Graphs/gXAxis.cpp @@ -164,7 +164,7 @@ void gXAxis::paint(gGraph & w,int left,int top, int width, int height) } for (qint64 i=aligned_start;iadd(px,top,px,top+6,linecol); qint64 j=i+tz_offset;