diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index de1c9f62..a16301a1 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -1120,7 +1120,7 @@ void gGraph::paint(int originX, int originY, int width, int height) if (m_selection.width()>0 && m_selecting_area) { QColor col(128,128,255,128); quads()->add(originX+m_selection.x(),originY+top, originX+m_selection.x()+m_selection.width(),originY+top,col); - quads()->add(originX+m_selection.x()+m_selection.width(),originY+height-top-bottom, originX+m_selection.x(),originY+height-top-bottom,col); + quads()->add(originX+m_selection.x()+m_selection.width(),originY+height-bottom, originX+m_selection.x(),originY+height-bottom,col); } } void gGraphView::queGraph(gGraph * g,int left, int top, int width, int height) @@ -1178,7 +1178,7 @@ void gGraph::mouseMoveEvent(QMouseEvent * event) //int y=event->pos().y(); int x=event->pos().x(); int x2=m_graphview->pointClicked().x();//,y2=m_graphview->pointClicked().y(); - int w=m_lastbounds.width()-(right+m_marginright); + int w=m_lastbounds.width()-(right); //int h=m_lastbounds.height()-(bottom+m_marginbottom); double xx=max_x-min_x; double xmult=xx/w; @@ -1196,7 +1196,7 @@ void gGraph::mouseMoveEvent(QMouseEvent * event) if (a2>w) a2=w; m_selecting_area=true; m_selection=QRect(a1-m_marginleft-1,0,a2-a1,m_lastbounds.height()); - double w2=m_lastbounds.width()-(right+m_marginright)-(m_marginleft+left); + double w2=m_lastbounds.width();-(right+m_marginright)-(m_marginleft+left); if (m_blockzoom) { xmult=(rmax_x-rmin_x)/w2; } else xmult=(max_x-min_x)/w2; diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index 03b212c5..abb01b74 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -44,7 +44,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh int x,y; - float bottom=start_py+height-25, top=start_py+25; + float bottom=start_py+height-25*w.printScaleY(), top=start_py+25*w.printScaleY(); double X; double Y; @@ -114,7 +114,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh if (lines->full()) { verts_exceeded=true; break; } if (xx<(1800000)) { GetTextExtent(m_label,x,y); - w.renderText(m_label,x1-(x/2),top-y+3); + w.renderText(m_label,x1-(x/2),top-y+(3*w.printScaleY())); } } diff --git a/Graphs/gXAxis.cpp b/Graphs/gXAxis.cpp index 0806c8e5..ecb11bf0 100644 --- a/Graphs/gXAxis.cpp +++ b/Graphs/gXAxis.cpp @@ -29,14 +29,16 @@ gXAxis::gXAxis(QColor col,bool fadeout) m_show_major_ticks=true; m_utcfix=false; m_fadeout=fadeout; - QDateTime d=QDateTime::currentDateTime(); - QTime t1=d.time(); - QTime t2=d.toUTC().time(); +// QDateTime d=QDateTime::currentDateTime(); +// QTime t1=d.time(); +// QTime t2=d.toUTC().time(); - tz_offset=t2.secsTo(t1); - tz_hours=tz_offset/3600.0; - tz_offset*=1000L; +// tz_offset=t2.secsTo(t1); +// tz_hours=tz_offset/3600.0; +// tz_offset*=1000L; + tz_offset=timezoneOffset(); + tz_hours=tz_offset/3600000.0; } gXAxis::~gXAxis() { diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index f5fe31bd..f661b567 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -98,6 +98,7 @@ bool EDFParser::Parse() serialnumber+=recordingident[i]; } QDateTime startDate=QDateTime::fromString(QString::fromAscii(header.datetime,16),"dd.MM.yyHH.mm.ss"); + //startDate.toTimeSpec(Qt::UTC); QDate d2=startDate.date(); if (d2.year()<2000) { d2.setYMD(d2.year()+100,d2.month(),d2.day()); @@ -108,13 +109,7 @@ bool EDFParser::Parse() return false; } startdate=qint64(startDate.toTime_t())*1000L; - QDateTime d=QDateTime::currentDateTime(); - QTime t1=d.time(); - QTime t2=d.toUTC().time(); - qint64 tz_offset=t2.secsTo(t1); - //tz_hours=tz_offset/3600.0; - tz_offset*=1000L; - startdate-=tz_offset; + //startdate-=timezoneOffset(); //qDebug() << startDate.toString("yyyy-MM-dd HH:mm:ss"); diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index 9ebf937d..ef660480 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -20,6 +20,20 @@ extern QProgressBar * qprogress; + +qint64 timezoneOffset() { + static bool ok=false; + static qint64 _TZ_offset=0; + + if (ok) return _TZ_offset; + QDateTime d1=QDateTime::currentDateTime(); + QDateTime d2=d1; + d1.setTimeSpec(Qt::UTC); + _TZ_offset=d2.secsTo(d1); + _TZ_offset*=1000L; + return _TZ_offset; +} + ////////////////////////////////////////////////////////////////////////////////////////// // Machine Base-Class implmementation ////////////////////////////////////////////////////////////////////////////////////////// @@ -321,8 +335,6 @@ bool Machine::Save() dir.mkdir(path); } - //size=sessionlist.size(); - QHash::iterator s; m_savelist.clear(); @@ -330,9 +342,6 @@ bool Machine::Save() cnt++; if ((*s)->IsChanged()) { m_savelist.push_back(*s); - //(*s)->UpdateSummaries(); - //(*s)->Store(path); - //(*s)->TrashEvents(); } } savelistCnt=0; diff --git a/SleepLib/machine.h b/SleepLib/machine.h index 4985be9f..383cebf2 100644 --- a/SleepLib/machine.h +++ b/SleepLib/machine.h @@ -130,6 +130,7 @@ public: protected: }; +qint64 timezoneOffset(); #endif // MACHINE_H diff --git a/daily.cpp b/daily.cpp index ed7efbd6..7f85d8af 100644 --- a/daily.cpp +++ b/daily.cpp @@ -599,6 +599,11 @@ void Daily::Load(QDate date) "a:link,a:visited { color: inherit; text-decoration: none; font-weight: normal;}" "a:hover { background-color: inherit; color: inherit; text-decoration:none; font-weight: bold; }" "" + "" "" "" "\n"; @@ -827,7 +832,7 @@ void Daily::Load(QDate date) } */ //} - html+="

"; + html+="

"; QDateTime fd,ld; bool corrupted_waveform=false; QString tooltip; @@ -844,7 +849,7 @@ void Daily::Load(QDate date) QHash::iterator i=(*s)->settings.find("BrokenWaveform"); tooltip=cpap->machine->GetClass()+" CPAP "+QString().sprintf("%2ih %2im %2is",h,m,s1); if ((i!=(*s)->settings.end()) && i.value().toBool()) corrupted_waveform=true; - tmp.sprintf(("").toLatin1(),(*s)->session(),(*s)->session()); + tmp.sprintf(("").toLatin1(),(*s)->session(),(*s)->session()); html+=tmp; } //if (oxi) html+=""; @@ -866,7 +871,7 @@ void Daily::Load(QDate date) html+=tmp; } } - html+="
%08i"+fd.date().toString(Qt::SystemLocaleShortDate)+""+fd.toString("HH:mm ")+""+ld.toString("HH:mm")+"
%08i"+fd.date().toString(Qt::SystemLocaleShortDate)+""+fd.toString("HH:mm ")+""+ld.toString("HH:mm")+"

"; + html+="
"; if (corrupted_waveform) { html+="
One or more waveform record for this session had faulty source data. Some waveform overlay points may not match up correctly.
"; } diff --git a/oximetry.cpp b/oximetry.cpp index 32cd2aff..4623cf38 100644 --- a/oximetry.cpp +++ b/oximetry.cpp @@ -1258,8 +1258,11 @@ void Oximetry::on_saveButton_clicked() if (m->SessionExists(session->session())) { m->sessionlist.erase(m->sessionlist.find(session->session())); } + // Forgetting to reset the session ID sucks, as it will delete sessions you don't want to delete.. + session->SetSessionID(qint64(session->first())/1000L); + m->AddSession(session,p_profile); - //} + oximeter->getMachine()->Save(); day->getSessions().clear();