From c96837d5b5e27445495c706e25c63218cb785275 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Wed, 21 Dec 2011 15:47:33 +1000 Subject: [PATCH] Make Overview weight use profile's UnitSystem. Remove the last of the String channelID references. --- Graphs/gSummaryChart.cpp | 11 +- Graphs/gYAxis.cpp | 9 +- SleepLib/calcs.cpp | 11 +- SleepLib/common.cpp | 37 ++++++ SleepLib/loader_plugins/prs1_loader.cpp | 14 +- SleepLib/loader_plugins/resmed_loader.cpp | 4 +- SleepLib/machine.cpp | 15 --- SleepLib/machine.h | 4 - SleepLib/machine_common.h | 153 ++++++++++++---------- SleepyHeadQT.pro | 3 +- daily.cpp | 40 +++--- docs/channels.xml | 4 +- mainwindow.cpp | 16 +-- overview.cpp | 11 +- 14 files changed, 185 insertions(+), 147 deletions(-) create mode 100644 SleepLib/common.cpp diff --git a/Graphs/gSummaryChart.cpp b/Graphs/gSummaryChart.cpp index 7671414c..058e4edd 100644 --- a/Graphs/gSummaryChart.cpp +++ b/Graphs/gSummaryChart.cpp @@ -133,9 +133,6 @@ void SummaryChart::SetDay(Day * nullday) type==ST_SESSIONS || day->settingExists(code) || day->hasData(code,type); - if (code==PRS1_FlexSet) { - int i=5; - } if (hascode) { m_days[dn]=day; @@ -620,6 +617,9 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) mx=mx+l_offset;//-86400000L; int zd=mx/86400000L; + UnitSystem us; + PROFILE["Units"]=="metric" ? us=US_Metric : US_Archiac; + Day * day; //if (hl_day!=zd) // This line is an optimization @@ -705,7 +705,10 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) } 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); + if (m_codes[i]==Journal_Weight) { + val=weightString(d.value()[i+1],us); + } else + val=QString::number(d.value()[i+1],'f',2); z+="\r\n"+chan.label()+" "+a+"="+val; //} } diff --git a/Graphs/gYAxis.cpp b/Graphs/gYAxis.cpp index f01afb94..3d16b2da 100644 --- a/Graphs/gYAxis.cpp +++ b/Graphs/gYAxis.cpp @@ -271,12 +271,5 @@ const QString gYAxisTime::Format(EventDataType v, int dp) const QString gYAxisWeight::Format(EventDataType v, int dp) { - if (m_unitsystem==US_Metric) { - return QString("%1kg").arg(v,0,'f',2); - } else if (m_unitsystem==US_Archiac) { - int oz=v / (float)ounce_convert; - int lb=oz / 16; - oz = oz % 16; - return QString("%1lb %2oz").arg(lb).arg(oz); - } + return weightString(v,m_unitsystem); } diff --git a/SleepLib/calcs.cpp b/SleepLib/calcs.cpp index ab95b6b2..4f54e4e5 100644 --- a/SleepLib/calcs.cpp +++ b/SleepLib/calcs.cpp @@ -493,9 +493,6 @@ int calcLeaks(Session *session) if (idx>=med.size()) idx--; median=tmp-med[idx]; if (median<0) median=0; - if (median>9999) { - int i=5; - } leak->AddEvent(ti,median); rpos=rpos % rbsize; @@ -606,10 +603,10 @@ int calcSPO2Drop(Session *session) int li=0; // Fix me.. Time scale varies. - const unsigned ringsize=30; - EventDataType ring[ringsize]={0}; - qint64 rtime[ringsize]={0}; - int rp=0; + //const unsigned ringsize=30; + //EventDataType ring[ringsize]={0}; + //qint64 rtime[ringsize]={0}; + //int rp=0; int min; int cnt=0; tmp=0; diff --git a/SleepLib/common.cpp b/SleepLib/common.cpp new file mode 100644 index 00000000..0dc4502c --- /dev/null +++ b/SleepLib/common.cpp @@ -0,0 +1,37 @@ +/* + SleepLib Common Functions + Copyright (c)2011 Mark Watkins + License: GPL +*/ + +#include +#include + +#include "machine_common.h" + +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; +} + + +QString weightString(float kg, UnitSystem us) +{ + if (us==US_Metric) { + return QString("%1kg").arg(kg,0,'f',2); + } else if (us==US_Archiac) { + int oz=(kg*1000.0) / (float)ounce_convert; + int lb=oz / 16.0; + oz = oz % 16; + return QString("%1lb %2oz").arg(lb,0,10).arg(oz); + } + return("Bad UnitSystem"); +} diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index c180d94d..6a150b3a 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -482,13 +482,13 @@ bool PRS1Loader::ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp, session->settings[PRS1_FlexSet]=(int)(data[offset+0x08] & 3); session->settings[PRS1_HumidSetting]=(int)data[offset+0x09]&0x0f; session->settings[PRS1_HumidStatus]=(data[offset+0x09]&0x80)==0x80; - session->settings["SysLock"]=(data[offset+0x0a]&0x80)==0x80; - session->settings["SysOneResistStat"]=(data[offset+0x0a]&0x40)==0x40; - session->settings["SysOneResistSet"]=(int)data[offset+0x0a]&7; - session->settings["HoseDiam"]=((data[offset+0x0a]&0x08)?"15mm":"22mm"); - session->settings["AutoOff"]=(data[offset+0x0c]&0x10)==0x10; - session->settings["MaskAlert"]=(data[offset+0x0c]&0x08)==0x08; - session->settings["ShowAHI"]=(data[offset+0x0c]&0x04)==0x04; + session->settings[PRS1_SysLock]=(data[offset+0x0a]&0x80)==0x80; + session->settings[PRS1_SysOneResistStat]=(data[offset+0x0a]&0x40)==0x40; + session->settings[PRS1_SysOneResistSet]=(int)data[offset+0x0a]&7; + session->settings[PRS1_HoseDiam]=((data[offset+0x0a]&0x08)?"15mm":"22mm"); + session->settings[PRS1_AutoOff]=(data[offset+0x0c]&0x10)==0x10; + session->settings[PRS1_MaskAlert]=(data[offset+0x0c]&0x08)==0x08; + session->settings[PRS1_ShowAHI]=(data[offset+0x0c]&0x04)==0x04; unsigned duration; diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index 94720a61..b2bdd4a4 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -426,12 +426,12 @@ int ResmedLoader::Open(QString & path,Profile *profile) // AutoSV machines don't have both fields sig=stredf.lookupSignal("EPR"); if (sig) { - sess->settings["EPR"]=sig->data[dn]; + sess->settings[RMS9_EPR]=sig->data[dn]; } sig=stredf.lookupSignal("EPRLevel"); if (sig) { - sess->settings["EPRSet"]=sig->data[dn]; + sess->settings[RMS9_EPRSet]=sig->data[dn]; } if (mode==0) { diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index 1abe3169..e7607c20 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -20,21 +20,6 @@ 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 ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/SleepLib/machine.h b/SleepLib/machine.h index 319ec90e..b046d491 100644 --- a/SleepLib/machine.h +++ b/SleepLib/machine.h @@ -182,10 +182,6 @@ public: protected: }; -// This should probably move somewhere else -//! \fn timezoneOffset(); -//! \brief Calculate the timezone Offset in milliseconds between system timezone and UTC -qint64 timezoneOffset(); #endif // MACHINE_H diff --git a/SleepLib/machine_common.h b/SleepLib/machine_common.h index cfca16fd..66f49080 100644 --- a/SleepLib/machine_common.h +++ b/SleepLib/machine_common.h @@ -30,6 +30,10 @@ class OldDBVersion {}; const quint32 magic=0xC73216AB; // Magic number for Sleepyhead Data Files.. Don't touch! //const int max_number_event_fields=10; +// This should probably move somewhere else +//! \fn timezoneOffset(); +//! \brief Calculate the timezone Offset in milliseconds between system timezone and UTC +qint64 timezoneOffset(); /*! \enum SummaryType @@ -47,6 +51,7 @@ enum UnitSystem { US_Metric, US_Archiac }; const float ounce_convert=28.3495231; const float pound_convert=ounce_convert*16; +QString weightString(EventDataType kg, UnitSystem us); /*! \enum CPAPMode \brief CPAP Machines mode of operation @@ -77,74 +82,90 @@ enum MCDataType { MC_bool=0, MC_int, MC_long, MC_float, MC_double, MC_string, MC_datetime }; // This all needs replacing with actual integer codes.. There will likely be a big speedup when this happens again. -const QString CPAP_IPAP="IPAP"; -const QString CPAP_IPAPLo="IPAPLo"; -const QString CPAP_IPAPHi="IPAPHi"; -const QString CPAP_EPAP="EPAP"; -const QString CPAP_Pressure="Pressure"; -const QString CPAP_PS="PS"; -const QString CPAP_Mode="PAPMode"; -const QString CPAP_BrokenSummary="BrokenSummary"; -const QString CPAP_PressureMin="PressureMin"; -const QString CPAP_PressureMax="PressureMax"; -const QString CPAP_RampTime="RampTime"; -const QString CPAP_RampPressure="RampPressure"; -const QString CPAP_Obstructive="Obstructive"; -const QString CPAP_Hypopnea="Hypopnea"; -const QString CPAP_ClearAirway="ClearAirway"; -const QString CPAP_Apnea="Apnea"; -const QString CPAP_CSR="CSR"; -const QString CPAP_LeakFlag="LeakFlag"; -const QString CPAP_ExP="ExP"; -const QString CPAP_NRI="NRI"; -const QString CPAP_VSnore="VSnore"; -const QString CPAP_VSnore2="VSnore2"; -const QString CPAP_RERA="RERA"; -const QString CPAP_PressurePulse="PressurePulse"; -const QString CPAP_FlowLimit="FlowLimit"; -const QString CPAP_FlowRate="FlowRate"; -const QString CPAP_MaskPressure="MaskPressure"; -const QString CPAP_MaskPressureHi="MaskPressureHi"; -const QString CPAP_RespEvent="RespEvent"; -const QString CPAP_Snore="Snore"; -const QString CPAP_MinuteVent="MinuteVent"; -const QString CPAP_RespRate="RespRate"; -const QString CPAP_TidalVolume="TidalVolume"; -const QString CPAP_PTB="PTB"; -const QString CPAP_Leak="Leak"; -const QString CPAP_LeakMedian="LeakMedian"; -const QString CPAP_LeakTotal="LeakTotal"; -const QString CPAP_MaxLeak="MaxLeak"; -const QString CPAP_FLG="FLG"; -const QString CPAP_IE="IE"; -const QString CPAP_Te="Te"; -const QString CPAP_Ti="Ti"; -const QString CPAP_TgMV="TgMV"; -const QString RMS9_E01="RMS9_E01"; -const QString RMS9_E02="RMS9_E02"; -const QString PRS1_00="PRS1_00"; -const QString PRS1_01="PRS1_01"; -const QString PRS1_08="PRS1_08"; -const QString PRS1_0A="PRS1_0A"; -const QString PRS1_0B="PRS1_0B"; -const QString PRS1_0C="PRS1_0C"; -const QString PRS1_0E="PRS1_0E"; -const QString PRS1_0F="PRS1_0F"; -const QString PRS1_10="PRS1_10"; -const QString PRS1_12="PRS1_12"; -const QString PRS1_FlexMode="FlexMode"; -const QString PRS1_FlexSet="FlexSet"; -const QString PRS1_HumidStatus="HumidStat"; -const QString PRS1_HumidSetting="HumidSet"; +const ChannelID CPAP_IPAP="IPAP"; +const ChannelID CPAP_IPAPLo="IPAPLo"; +const ChannelID CPAP_IPAPHi="IPAPHi"; +const ChannelID CPAP_EPAP="EPAP"; +const ChannelID CPAP_Pressure="Pressure"; +const ChannelID CPAP_PS="PS"; +const ChannelID CPAP_Mode="PAPMode"; +const ChannelID CPAP_BrokenSummary="BrokenSummary"; +const ChannelID CPAP_PressureMin="PressureMin"; +const ChannelID CPAP_PressureMax="PressureMax"; +const ChannelID CPAP_RampTime="RampTime"; +const ChannelID CPAP_RampPressure="RampPressure"; +const ChannelID CPAP_Obstructive="Obstructive"; +const ChannelID CPAP_Hypopnea="Hypopnea"; +const ChannelID CPAP_ClearAirway="ClearAirway"; +const ChannelID CPAP_Apnea="Apnea"; +const ChannelID CPAP_CSR="CSR"; +const ChannelID CPAP_LeakFlag="LeakFlag"; +const ChannelID CPAP_ExP="ExP"; +const ChannelID CPAP_NRI="NRI"; +const ChannelID CPAP_VSnore="VSnore"; +const ChannelID CPAP_VSnore2="VSnore2"; +const ChannelID CPAP_RERA="RERA"; +const ChannelID CPAP_PressurePulse="PressurePulse"; +const ChannelID CPAP_FlowLimit="FlowLimit"; +const ChannelID CPAP_FlowRate="FlowRate"; +const ChannelID CPAP_MaskPressure="MaskPressure"; +const ChannelID CPAP_MaskPressureHi="MaskPressureHi"; +const ChannelID CPAP_RespEvent="RespEvent"; +const ChannelID CPAP_Snore="Snore"; +const ChannelID CPAP_MinuteVent="MinuteVent"; +const ChannelID CPAP_RespRate="RespRate"; +const ChannelID CPAP_TidalVolume="TidalVolume"; +const ChannelID CPAP_PTB="PTB"; +const ChannelID CPAP_Leak="Leak"; +const ChannelID CPAP_LeakMedian="LeakMedian"; +const ChannelID CPAP_LeakTotal="LeakTotal"; +const ChannelID CPAP_MaxLeak="MaxLeak"; +const ChannelID CPAP_FLG="FLG"; +const ChannelID CPAP_IE="IE"; +const ChannelID CPAP_Te="Te"; +const ChannelID CPAP_Ti="Ti"; +const ChannelID CPAP_TgMV="TgMV"; +const ChannelID RMS9_E01="RMS9_E01"; +const ChannelID RMS9_E02="RMS9_E02"; +const ChannelID RMS9_EPR="EPR"; +const ChannelID RMS9_EPRSet="EPRSet"; +const ChannelID PRS1_00="PRS1_00"; +const ChannelID PRS1_01="PRS1_01"; +const ChannelID PRS1_08="PRS1_08"; +const ChannelID PRS1_0A="PRS1_0A"; +const ChannelID PRS1_0B="PRS1_0B"; +const ChannelID PRS1_0C="PRS1_0C"; +const ChannelID PRS1_0E="PRS1_0E"; +const ChannelID PRS1_0F="PRS1_0F"; +const ChannelID PRS1_10="PRS1_10"; +const ChannelID PRS1_12="PRS1_12"; +const ChannelID PRS1_FlexMode="FlexMode"; +const ChannelID PRS1_FlexSet="FlexSet"; +const ChannelID PRS1_HumidStatus="HumidStat"; +const ChannelID PRS1_HumidSetting="HumidSet"; +const ChannelID PRS1_SysLock="SysLock"; +const ChannelID PRS1_SysOneResistStat="SysOneResistStat"; +const ChannelID PRS1_SysOneResistSet="SysOneResistSet"; +const ChannelID PRS1_HoseDiam="HoseDiam"; +const ChannelID PRS1_AutoOn="AutoOn"; +const ChannelID PRS1_AutoOff="AutoOff"; +const ChannelID PRS1_MaskAlert="MaskAlert"; +const ChannelID PRS1_ShowAHI="ShowAHI"; -const QString OXI_Pulse="Pulse"; -const QString OXI_SPO2="SPO2"; -const QString OXI_PulseChange="PulseChange"; -const QString OXI_SPO2Drop="SPO2Drop"; -const QString OXI_Plethy="Plethy"; -const QString CPAP_AHI="AHI"; -const QString Journal_Notes="Journal"; +const ChannelID OXI_Pulse="Pulse"; +const ChannelID OXI_SPO2="SPO2"; +const ChannelID OXI_PulseChange="PulseChange"; +const ChannelID OXI_SPO2Drop="SPO2Drop"; +const ChannelID OXI_Plethy="Plethy"; +const ChannelID CPAP_AHI="AHI"; +const ChannelID Journal_Notes="Journal"; +const ChannelID Journal_Weight="Weight"; +const ChannelID Journal_BMI="BMI"; +const ChannelID Journal_ZombieMeter="ZombieMeter"; +const ChannelID Bookmark_Start="BookmarkStart"; +const ChannelID Bookmark_End="BookmarkEnd"; +const ChannelID Bookmark_Notes="BookmarkNotes"; #endif // MACHINE_COMMON_H diff --git a/SleepyHeadQT.pro b/SleepyHeadQT.pro index 8a294d5c..d9274d79 100644 --- a/SleepyHeadQT.pro +++ b/SleepyHeadQT.pro @@ -78,7 +78,8 @@ SOURCES += main.cpp\ quazip/quaadler32.cpp \ quazip/qioapi.cpp \ quazip/JlCompress.cpp \ - UpdaterWindow.cpp + UpdaterWindow.cpp \ + SleepLib/common.cpp unix:SOURCES += qextserialport/posix_qextserialport.cpp unix:!macx:SOURCES += qextserialport/qextserialenumerator_unix.cpp diff --git a/daily.cpp b/daily.cpp index 37461bbe..d524fad7 100644 --- a/daily.cpp +++ b/daily.cpp @@ -957,8 +957,8 @@ void Daily::Load(QDate date) if (journal->settings.contains(Journal_Notes)) ui->JournalNotes->setHtml(journal->settings[Journal_Notes].toString()); - if (journal->settings.contains("Weight")) { - double kg=journal->settings["Weight"].toDouble(&ok); + if (journal->settings.contains(Journal_Weight)) { + double kg=journal->settings[Journal_Weight].toDouble(&ok); if (PROFILE["Units"].toString()=="metric") { ui->weightSpinBox->setDecimals(3); ui->weightSpinBox->blockSignals(true); @@ -993,16 +993,16 @@ void Daily::Load(QDate date) } } - if (journal->settings.contains("ZombieMeter")) { + if (journal->settings.contains(Journal_ZombieMeter)) { ui->ZombieMeter->blockSignals(true); - ui->ZombieMeter->setValue(journal->settings["ZombieMeter"].toDouble(&ok)); + ui->ZombieMeter->setValue(journal->settings[Journal_ZombieMeter].toDouble(&ok)); ui->ZombieMeter->blockSignals(false); } - if (journal->settings.contains("BookmarkStart")) { - QVariantList start=journal->settings["BookmarkStart"].toList(); - QVariantList end=journal->settings["BookmarkEnd"].toList(); - QStringList notes=journal->settings["BookmarkNotes"].toStringList(); + if (journal->settings.contains(Bookmark_Start)) { + QVariantList start=journal->settings[Bookmark_Start].toList(); + QVariantList end=journal->settings[Bookmark_End].toList(); + QStringList notes=journal->settings[Bookmark_Notes].toStringList(); ui->bookmarkTable->blockSignals(true); @@ -1402,9 +1402,9 @@ void Daily::update_Bookmarks() journal=CreateJournalSession(previous_date); } - journal->settings["BookmarkStart"]=start; - journal->settings["BookmarkEnd"]=end; - journal->settings["BookmarkNotes"]=notes; + journal->settings[Bookmark_Start]=start; + journal->settings[Bookmark_End]=end; + journal->settings[Bookmark_Notes]=notes; journal->SetChanged(true); BookmarksChanged=true; } @@ -1427,7 +1427,7 @@ void Daily::on_ZombieMeter_valueChanged(int action) if (!journal) { journal=CreateJournalSession(previous_date); } - journal->settings["ZombieMeter"]=ui->ZombieMeter->value(); + journal->settings[Journal_ZombieMeter]=ui->ZombieMeter->value(); journal->SetChanged(true); gGraph *g; @@ -1458,20 +1458,20 @@ void Daily::on_weightSpinBox_valueChanged(double arg1) else { kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert); } - journal->settings["Weight"]=kg; + journal->settings[Journal_Weight]=kg; gGraphView *gv=mainwin->getOverview()->graphView(); gGraph *g; if (gv) { - g=gv->findGraph("Weight"); + g=gv->findGraph(tr("Weight")); if (g) g->setDay(NULL); } if ((height>0) && (kg>0)) { double bmi=kg/(height * height); ui->BMI->display(bmi); ui->BMI->setVisible(true); - journal->settings["BMI"]=bmi; + journal->settings[Journal_BMI]=bmi; if (gv) { - g=gv->findGraph("BMI"); + g=gv->findGraph(tr("BMI")); if (g) g->setDay(NULL); } } @@ -1486,12 +1486,12 @@ void Daily::on_ouncesSpinBox_valueChanged(int arg1) } double height=PROFILE["Height"].toDouble(&ok)/100.0; double kg=(ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert); - journal->settings["Weight"]=kg; + journal->settings[Journal_Weight]=kg; gGraph *g; if (mainwin->getOverview()) { - g=mainwin->getOverview()->graphView()->findGraph("Weight"); + g=mainwin->getOverview()->graphView()->findGraph(tr("Weight")); if (g) g->setDay(NULL); } @@ -1500,9 +1500,9 @@ void Daily::on_ouncesSpinBox_valueChanged(int arg1) ui->BMI->display(bmi); ui->BMI->setVisible(true); - journal->settings["BMI"]=bmi; + journal->settings[Journal_BMI]=bmi; if (mainwin->getOverview()) { - g=mainwin->getOverview()->graphView()->findGraph("BMI"); + g=mainwin->getOverview()->graphView()->findGraph(tr("BMI")); if (g) g->setDay(NULL); } } diff --git a/docs/channels.xml b/docs/channels.xml index 2c1f4e41..bee6b226 100644 --- a/docs/channels.xml +++ b/docs/channels.xml @@ -90,9 +90,11 @@ One id code per item - + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index 31e92408..fbfe3463 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -665,7 +665,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) int visgraphs=gv->visibleGraphs(); if (visgraphs==0) { - Notify("There are no graphs visible to print"); + Notify(tr("There are no graphs visible to print")); return; } @@ -675,10 +675,10 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) if (name=="Daily") { QVariantList book_start; journal=getDaily()->GetJournalSession(getDaily()->getDate()); - if (journal && journal->settings.contains("BookmarkStart")) { - book_start=journal->settings["BookmarkStart"].toList(); + if (journal && journal->settings.contains(Bookmark_Start)) { + book_start=journal->settings[Bookmark_Start].toList(); if (book_start.size()>0) { - if (QMessageBox::question(this,"Bookmarks","Would you like to show bookmarked areas in this report?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { + if (QMessageBox::question(this,tr("Bookmarks"),tr("Would you like to show bookmarked areas in this report?"),QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { print_bookmarks=true; } } @@ -913,10 +913,10 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) graphs.push_back(g); labels.push_back(tr("Current Selection")); if (journal) { - if (journal->settings.contains("BookmarkStart")) { - QVariantList st1=journal->settings["BookmarkStart"].toList(); - QVariantList et1=journal->settings["BookmarkEnd"].toList(); - QStringList notes=journal->settings["BookmarkNotes"].toStringList(); + if (journal->settings.contains(Bookmark_Start)) { + QVariantList st1=journal->settings[Bookmark_Start].toList(); + QVariantList et1=journal->settings[Bookmark_End].toList(); + QStringList notes=journal->settings[Bookmark_Notes].toStringList(); for (int i=0;isetMachineType(MT_JOURNAL); - weight->addSlice("Weight",QColor("black"),ST_SETAVG,true); + weight->addSlice(Journal_Weight,QColor("black"),ST_SETAVG,true); WEIGHT->AddLayer(weight); bmi=new SummaryChart(tr("BMI"),GT_LINE); bmi->setMachineType(MT_JOURNAL); - bmi->addSlice("BMI",QColor("dark blue"),ST_SETAVG,true); + bmi->addSlice(Journal_BMI,QColor("dark blue"),ST_SETAVG,true); BMI->AddLayer(bmi); zombie=new SummaryChart(tr("Zombie Meter"),GT_LINE); zombie->setMachineType(MT_JOURNAL); - zombie->addSlice("ZombieMeter",QColor("dark red"),ST_SETAVG,true); + zombie->addSlice(Journal_ZombieMeter,QColor("dark red"),ST_SETAVG,true); ZOMBIE->AddLayer(zombie); pulse=new SummaryChart(tr("Pulse Rate"),GT_LINE); @@ -242,7 +243,9 @@ gGraph * Overview::createGraph(QString name,QString units, YTickerType yttype) yt=new gYAxisTime(true); // Time scale break; case YT_Weight: - yt=new gYAxisWeight(US_Archiac); // Weight scale, which adjusts for UnitSystem + if (PROFILE["Units"].toString()=="metric") { + yt=new gYAxisWeight(US_Metric); + } else yt=new gYAxisWeight(US_Archiac); break; default: yt=new gYAxis(); // Plain numeric scale