diff --git a/Graphs/gSummaryChart.cpp b/Graphs/gSummaryChart.cpp index 058e4edd..95cbfc4d 100644 --- a/Graphs/gSummaryChart.cpp +++ b/Graphs/gSummaryChart.cpp @@ -617,9 +617,6 @@ 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 @@ -706,7 +703,7 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event) //if (day && (day->channelExists(m_codes[i]) || day->settingExists(m_codes[i]))) { schema::Channel & chan=schema::channel[m_codes[i]]; if (m_codes[i]==Journal_Weight) { - val=weightString(d.value()[i+1],us); + val=weightString(d.value()[i+1],unitSystem()); } else val=QString::number(d.value()[i+1],'f',2); z+="\r\n"+chan.label()+" "+a+"="+val; diff --git a/SleepLib/common.cpp b/SleepLib/common.cpp index 0dc4502c..ce52fe11 100644 --- a/SleepLib/common.cpp +++ b/SleepLib/common.cpp @@ -5,9 +5,8 @@ */ #include -#include -#include "machine_common.h" +#include "profiles.h" qint64 timezoneOffset() { static bool ok=false; @@ -23,6 +22,23 @@ qint64 timezoneOffset() { } +UnitSystem unitSystem(bool reset) +{ + static bool cached=false; + static UnitSystem us=US_Undefined; + if (!reset && cached) return us; + + if (!p_profile) return US_Undefined; + if (PROFILE["Units"].toString()=="metric") + us=US_Metric; + else if (PROFILE["Units"].toString()=="archiac") + us=US_Archiac; + else return US_Undefined; + + cached=true; + return us; +} + QString weightString(float kg, UnitSystem us) { if (us==US_Metric) { diff --git a/SleepLib/common.h b/SleepLib/common.h new file mode 100644 index 00000000..880feec5 --- /dev/null +++ b/SleepLib/common.h @@ -0,0 +1,18 @@ +#ifndef COMMON_H +#define COMMON_H + +#include + +enum UnitSystem { US_Undefined, US_Metric, US_Archiac }; + +UnitSystem unitSystem(bool reset=true); + +const float ounce_convert=28.3495231; // grams +const float pound_convert=ounce_convert*16; + +QString weightString(float kg, UnitSystem us); + + + + +#endif // COMMON_H diff --git a/SleepLib/day.h b/SleepLib/day.h index 3e465fe0..6e77133f 100644 --- a/SleepLib/day.h +++ b/SleepLib/day.h @@ -7,6 +7,7 @@ #ifndef DAY_H #define DAY_H +#include "SleepLib/common.h" #include "SleepLib/machine_common.h" #include "SleepLib/machine.h" #include "SleepLib/event.h" diff --git a/SleepLib/machine_common.h b/SleepLib/machine_common.h index 66f49080..b0fff615 100644 --- a/SleepLib/machine_common.h +++ b/SleepLib/machine_common.h @@ -47,11 +47,6 @@ enum SummaryType { ST_CNT, ST_SUM, ST_AVG, ST_WAVG, ST_90P, ST_MIN, ST_MAX, ST_C enum MachineType { MT_UNKNOWN=0,MT_CPAP,MT_OXIMETER,MT_SLEEPSTAGE,MT_JOURNAL }; //void InitMapsWithoutAwesomeInitializerLists(); -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 @@ -151,7 +146,8 @@ const ChannelID PRS1_AutoOn="AutoOn"; const ChannelID PRS1_AutoOff="AutoOff"; const ChannelID PRS1_MaskAlert="MaskAlert"; const ChannelID PRS1_ShowAHI="ShowAHI"; - +const ChannelID CPAP_UserFlag1="UserFlag1"; +const ChannelID CPAP_UserFlag2="UserFlag2"; const ChannelID OXI_Pulse="Pulse"; const ChannelID OXI_SPO2="SPO2"; diff --git a/SleepLib/profiles.cpp b/SleepLib/profiles.cpp index a8d67f5d..0d7b6860 100644 --- a/SleepLib/profiles.cpp +++ b/SleepLib/profiles.cpp @@ -32,7 +32,14 @@ Profile::Profile() p_name="Profile"; p_path=PREF.Get("{home}/Profiles"); machlist.clear(); - //m_first=m_last= + + doctor=new DoctorInfo(this); + user=new UserInfo(this); + cpap=new CPAPSettings(this); + oxi=new OxiSettings(this); + appearance=new AppearanceSettings(this); + import=new ImportSettings(this); + settings=new UserSettings(this); } Profile::Profile(QString path) :Preferences(),is_first_day(true) @@ -45,7 +52,14 @@ Profile::Profile(QString path) if (!p_path.endsWith("/")) p_path+="/"; p_filename=p_path+p_name+xmlext; machlist.clear(); - //m_first=m_last=NULL; + + doctor=new DoctorInfo(this); + user=new UserInfo(this); + cpap=new CPAPSettings(this); + oxi=new OxiSettings(this); + appearance=new AppearanceSettings(this); + import=new ImportSettings(this); + settings=new UserSettings(this); } bool Profile::Save(QString filename) { @@ -95,6 +109,13 @@ bool Profile::Save(QString filename) Profile::~Profile() { + delete user; + delete doctor; + delete cpap; + delete oxi; + delete appearance; + delete import; + delete settings; for (QHash::iterator i=machlist.begin(); i!=machlist.end(); i++) { delete i.value(); } @@ -521,3 +542,67 @@ void Scan() } // namespace Profiles +const char * DI_STR_Name="DoctorName"; +const char * DI_STR_Phone="DoctorPhone"; +const char * DI_STR_Practice="DoctorPractice"; +const char * DI_STR_Address="DoctorAddress"; +const char * DI_STR_PatientID="DoctorPatientID"; + +const char * UI_STR_DOB="DOB"; +const char * UI_STR_FirstName="FirstName"; +const char * UI_STR_LastName="LastName"; +const char * UI_STR_UserName="UserName"; +const char * UI_STR_Password="Password"; +const char * UI_STR_Address="Address"; +const char * UI_STR_Phone="Phone"; +const char * UI_STR_EmailAddress="EmailAddress"; +const char * UI_STR_Country="Country"; +const char * UI_STR_Height="Height"; +const char * UI_STR_Gender="Gender"; +const char * UI_STR_TimeZone="TimeZone"; +const char * UI_STR_Language="Language"; +const char * UI_STR_DST="DST"; + +const char * OS_STR_EnableOximetry="EnableOximetry"; +const char * OS_STR_SyncOximetry="SyncOximetry"; +const char * OS_STR_OximeterType="OximeterType"; +const char * OS_STR_OxiDiscardThreshold="OxiDiscardThreshold"; +const char * OS_STR_SPO2DropDuration="SPO2DropDuration"; +const char * OS_STR_SPO2DropPercentage="SPO2DropPercentage"; +const char * OS_STR_PulseChangeDuration="PulseChangeDuration"; +const char * OS_STR_PulseChangeBPM="PulseChangeBPM"; + +const char * CS_STR_ComplianceHours="ComplianceHours"; +const char * CS_STR_ShowCompliance="ShowCompliance"; +const char * CS_STR_ShowLeaksMode="ShowLeaksMode"; +const char * CS_STR_MaskStartDate="MaskStartDate"; +const char * CS_STR_MaskDescription="MaskDescription"; +const char * CS_STR_MaskType="MaskType"; +const char * CS_STR_PrescribedMode="CPAPPrescribedMode"; +const char * CS_STR_PrescribedMinPressure="CPAPPrescribedMinPressure"; +const char * CS_STR_PrescribedMaxPressure="CPAPPrescribedMaxPressure"; +const char * CS_STR_UntreatedAHI="UntreatedAHI"; +const char * CS_STR_Notes="CPAPNotes"; +const char * CS_STR_DateDiagnosed="DateDiagnosed"; + +const char * IS_STR_DaySplitTime="DaySplitTime"; +const char * IS_STR_CacheSessions="MemoryHog"; +const char * IS_STR_CombineCloseSessions="CombineCloserSessions"; +const char * IS_STR_IgnoreShorterSessions="IgnoreShorterSessions"; +const char * IS_STR_Multithreading="EnableMultithreading"; + +const char * AS_STR_GraphHeight="GraphHeight"; +const char * AS_STR_AntiAliasing="UseAntiAliasing"; +const char * AS_STR_HighResPrinting="HighResPrinting"; +const char * AS_STR_GraphSnapshots="EnableGraphSnapshots"; +const char * AS_STR_Animations="AnimationsAndTransitions"; +const char * AS_STR_SquareWave="SquareWavePlots"; +const char * AS_STR_OverlayType="OverlayType"; + +const char * US_STR_UnitSystem="UnitSystem"; +const char * US_STR_EventWindowSize="EventWindowSize"; +const char * US_STR_SkipEmptyDays="SkipEmptyDays"; +const char * US_STR_RebuildCache="RebuildCache"; +const char * US_STR_TrashDayCache="TrashDayCache"; +const char * US_STR_ShowDebug="ShowDebug"; +const char * US_STR_LinkGroups="LinkGroups"; diff --git a/SleepLib/profiles.h b/SleepLib/profiles.h index d2f06671..a41e4d18 100644 --- a/SleepLib/profiles.h +++ b/SleepLib/profiles.h @@ -11,12 +11,28 @@ License: GPL #define PROFILES_H #include +#include +#include #include "machine.h" #include "machine_loader.h" #include "preferences.h" class Machine; +enum Gender { GenderNotSpecified, Male, Female }; +enum MaskType { Mask_Unknown, Mask_NasalPillows, Mask_Hybrid, Mask_StandardNasal, Mask_FullFace }; +enum OverlayDisplayType { ODT_Bars, ODT_TopAndBottom }; + +class DoctorInfo; +class UserInfo; +class UserSettings; +class OxiSettings; +class CPAPSettings; +class AppearanceSettings; +class ImportSettings; + + + /*! \class Profile \author Mark Watkins @@ -76,6 +92,9 @@ public: //! \brief return the first machine of type t Machine * GetMachine(MachineType t); + //! \brief Returns true if this profile stores this variable identified by key + bool contains(QString key) { return p_preferences.contains(key); } + virtual void ExtraLoad(QDomElement & root); virtual QDomElement ExtraSave(QDomDocument & doc); @@ -83,6 +102,17 @@ public: const QDate & FirstDay() { return m_first; } const QDate & LastDay() { return m_last; } + QString dataFolder() { return (*this).Get("{DataFolder}"); } + + UserInfo *user; + CPAPSettings *cpap; + OxiSettings *oxi; + DoctorInfo *doctor; + AppearanceSettings *appearance; + UserSettings *settings; + ImportSettings *import; + + protected: QDate m_first,m_last; @@ -100,6 +130,400 @@ extern Profile * p_profile; #define LAYOUT (*p_layout) #define PROFILE (*p_profile) +extern const char * DI_STR_Name; +extern const char * DI_STR_Phone; +extern const char * DI_STR_Practice; +extern const char * DI_STR_Address; +extern const char * DI_STR_PatientID; + +class DoctorInfo +{ +public: + DoctorInfo(Profile *p) : m_profile(p) + { + if (!m_profile->contains(DI_STR_Name)) (*m_profile)[DI_STR_Name]=QString(); + if (!m_profile->contains(DI_STR_Phone)) (*m_profile)[DI_STR_Phone]=QString(); + if (!m_profile->contains(DI_STR_Practice)) (*m_profile)[DI_STR_Practice]=QString(); + if (!m_profile->contains(DI_STR_Address)) (*m_profile)[DI_STR_Address]=QString(); + if (!m_profile->contains(DI_STR_PatientID)) (*m_profile)[DI_STR_PatientID]=QString(); + } + ~DoctorInfo() {} + void setProfile(Profile *p) { m_profile=p; } + + const QString name() { return (*m_profile)[DI_STR_Name].toString(); } + const QString phone() { return (*m_profile)[DI_STR_Phone].toString(); } + const QString practiceName() { return (*m_profile)[DI_STR_Practice].toString(); } + const QString address() { return (*m_profile)[DI_STR_Address].toString(); } + const QString patiendID() { return (*m_profile)[DI_STR_PatientID].toString(); } + + void setName(QString name) { (*m_profile)[DI_STR_Name]=name; } + void setPhone(QString phone) { (*m_profile)[DI_STR_Phone]=phone; } + void setPracticeName(QString practice) { (*m_profile)[DI_STR_Practice]=practice; } + void setAddress(QString address) { (*m_profile)[DI_STR_Address]=address; } + void setPatiendID(QString pid) { (*m_profile)[DI_STR_PatientID]=pid; } + + Profile *m_profile; +}; + +extern const char * UI_STR_DOB; +extern const char * UI_STR_FirstName; +extern const char * UI_STR_LastName; +extern const char * UI_STR_UserName; +extern const char * UI_STR_Password; +extern const char * UI_STR_Address; +extern const char * UI_STR_Phone; +extern const char * UI_STR_EmailAddress; +extern const char * UI_STR_Country; +extern const char * UI_STR_Height; +extern const char * UI_STR_Gender; +extern const char * UI_STR_TimeZone; +extern const char * UI_STR_Language; +extern const char * UI_STR_DST; + +/*! \class UserInfo + \brief Profile Options relating to the User Information + */ +class UserInfo +{ +public: + //! \brief Create UserInfo object given Profile *p, and initialize the defaults + UserInfo(Profile *p) : m_profile(p) + { + if (!m_profile->contains(UI_STR_DOB)) (*m_profile)[UI_STR_DOB]=QDate(1970,1,1); + if (!m_profile->contains(UI_STR_FirstName)) (*m_profile)[UI_STR_FirstName]=QString(); + if (!m_profile->contains(UI_STR_LastName)) (*m_profile)[UI_STR_LastName]=QString(); + if (!m_profile->contains(UI_STR_UserName)) (*m_profile)[UI_STR_UserName]=QString(); + if (!m_profile->contains(UI_STR_Password)) (*m_profile)[UI_STR_Password]=QString(); + if (!m_profile->contains(UI_STR_Address)) (*m_profile)[UI_STR_Address]=QString(); + if (!m_profile->contains(UI_STR_Phone)) (*m_profile)[UI_STR_Phone]=QString(); + if (!m_profile->contains(UI_STR_EmailAddress)) (*m_profile)[UI_STR_EmailAddress]=QString(); + if (!m_profile->contains(UI_STR_Country)) (*m_profile)[UI_STR_Country]=QString(); + if (!m_profile->contains(UI_STR_Height)) (*m_profile)[UI_STR_Height]=0.0; + if (!m_profile->contains(UI_STR_Gender)) (*m_profile)[UI_STR_Gender]=(int)GenderNotSpecified; + if (!m_profile->contains(UI_STR_TimeZone)) (*m_profile)[UI_STR_TimeZone]=QString(); + if (!m_profile->contains(UI_STR_Language)) (*m_profile)[UI_STR_Language]="English"; + if (!m_profile->contains(UI_STR_DST)) (*m_profile)[UI_STR_DST]=false; + + } + ~UserInfo() {} + + void setProfile(Profile *p) { m_profile=p; } + + QDate DOB() { return (*m_profile)[UI_STR_DOB].toDate(); } + const QString firstName() { return (*m_profile)[UI_STR_FirstName].toString(); } + const QString lastName() { return (*m_profile)[UI_STR_LastName].toString(); } + const QString userName() { return (*m_profile)[UI_STR_UserName].toString(); } + const QString address() { return (*m_profile)[UI_STR_Address].toString(); } + const QString phone() { return (*m_profile)[UI_STR_Phone].toString(); } + const QString email() { return (*m_profile)[UI_STR_EmailAddress].toString(); } + double height() { return (*m_profile)[UI_STR_Height].toDouble(); } + const QString country() { return (*m_profile)[UI_STR_Country].toString(); } + Gender gender() { return (Gender)(*m_profile)[UI_STR_Gender].toInt(); } + const QString timeZone() { return (*m_profile)[UI_STR_TimeZone].toString(); } + const QString language() { return (*m_profile)[UI_STR_Language].toString(); } + bool daylightSaving() { return (*m_profile)[UI_STR_DST].toBool(); } + + void setDOB(QDate date) { (*m_profile)[UI_STR_DOB]=date; } + void setFirstName(QString name) { (*m_profile)[UI_STR_FirstName]=name; } + void setLastName(QString name) { (*m_profile)[UI_STR_LastName]=name; } + void setUserName(QString username) { (*m_profile)[UI_STR_UserName]=username; } + void setAddress(QString address) { (*m_profile)[UI_STR_Address]=address; } + void setPhone(QString phone) { (*m_profile)[UI_STR_Phone]=phone; } + void setEmail(QString email) { (*m_profile)[UI_STR_EmailAddress]=email; } + void setHeight(double height) { (*m_profile)[UI_STR_Height]=height; } + void setCountry(QString country) { (*m_profile)[UI_STR_Country]=country; } + void setGender(Gender g) { (*m_profile)[UI_STR_Gender]=(int)g; } + void setTimeZone(QString tz) { (*m_profile)[UI_STR_TimeZone]=tz; } + void setLanguage(QString language) { (*m_profile)[UI_STR_Language]=language; } + void setDaylightSaving(bool ds) { (*m_profile)[UI_STR_DST]=ds; } + + bool checkPassword(QString password) { + QByteArray ba=password.toUtf8(); + return ((*m_profile)[UI_STR_Password].toString()==QString(QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex())); + } + void setPassword(QString password) { + QByteArray ba=password.toUtf8(); + // Hash me. + (*m_profile)[UI_STR_Password]=QString(QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex()); + } + + Profile *m_profile; +}; + +extern const char * OS_STR_EnableOximetry; +extern const char * OS_STR_SyncOximetry; +extern const char * OS_STR_OximeterType; +extern const char * OS_STR_OxiDiscardThreshold; +extern const char * OS_STR_SPO2DropDuration; +extern const char * OS_STR_SPO2DropPercentage; +extern const char * OS_STR_PulseChangeDuration; +extern const char * OS_STR_PulseChangeBPM; + +/*! \class OxiSettings + \brief Profile Options relating to the Oximetry settings + */ +class OxiSettings +{ +public: + //! \brief Create OxiSettings object given Profile *p, and initialize the defaults + OxiSettings(Profile *p) :m_profile(p) + { + if (m_profile->contains(OS_STR_EnableOximetry)) (*m_profile)[OS_STR_EnableOximetry]=false; + if (m_profile->contains(OS_STR_SyncOximetry)) (*m_profile)[OS_STR_SyncOximetry]=true; + if (m_profile->contains(OS_STR_OximeterType)) (*m_profile)[OS_STR_OximeterType]="CMS50"; + if (m_profile->contains(OS_STR_OxiDiscardThreshold)) (*m_profile)[OS_STR_OxiDiscardThreshold]=0.0; + if (m_profile->contains(OS_STR_SPO2DropDuration)) (*m_profile)[OS_STR_SPO2DropDuration]=8.0; + if (m_profile->contains(OS_STR_SPO2DropPercentage)) (*m_profile)[OS_STR_SPO2DropPercentage]=3.0; + if (m_profile->contains(OS_STR_PulseChangeDuration)) (*m_profile)[OS_STR_PulseChangeDuration]=8.0; + if (m_profile->contains(OS_STR_PulseChangeBPM)) (*m_profile)[OS_STR_PulseChangeBPM]=5.0; + } + ~OxiSettings() {} + + void setProfile(Profile *p) { m_profile=p; } + + bool oximetryEnabled() { return (*m_profile)[OS_STR_EnableOximetry].toBool(); } + bool syncOximetry() { return (*m_profile)[OS_STR_SyncOximetry].toBool(); } + QString oximeterType() { return (*m_profile)[OS_STR_OximeterType].toString(); } + double oxiDiscardThreshold() { return (*m_profile)[OS_STR_OxiDiscardThreshold].toDouble(); } + double spO2DropDuration() { return (*m_profile)[OS_STR_SPO2DropDuration].toDouble(); } + double spO2DropPercentage() { return (*m_profile)[OS_STR_SPO2DropPercentage].toDouble(); } + double pulseChangeDuration() { return (*m_profile)[OS_STR_PulseChangeDuration].toDouble(); } + double pulseChangeBPM() { return (*m_profile)[OS_STR_PulseChangeBPM].toDouble(); } + + void setOximetryEnabled(bool enabled) { (*m_profile)[OS_STR_EnableOximetry]=enabled; } + void setSyncOximetry(bool synced) { (*m_profile)[OS_STR_SyncOximetry]=synced; } + void setOximeterType(QString oxitype) { (*m_profile)[OS_STR_OximeterType]=oxitype; } + void setOxiDiscardThreshold(double thresh) { (*m_profile)[OS_STR_OxiDiscardThreshold]=thresh; } + void setSpO2DropDuration(double duration) { (*m_profile)[OS_STR_SPO2DropDuration]=duration; } + void setSpO2DropPercentage(double percentage) { (*m_profile)[OS_STR_SPO2DropPercentage]=percentage; } + void setPulseChangeDuration(double duration) { (*m_profile)[OS_STR_PulseChangeDuration]=duration; } + void setPulseChangeBPM(double bpm) { (*m_profile)[OS_STR_PulseChangeBPM]=bpm; } + + Profile *m_profile; +}; + +extern const char * CS_STR_ComplianceHours; +extern const char * CS_STR_ShowCompliance; +extern const char * CS_STR_ShowLeaksMode; +extern const char * CS_STR_MaskStartDate; +extern const char * CS_STR_MaskDescription; +extern const char * CS_STR_MaskType; +extern const char * CS_STR_PrescribedMode; +extern const char * CS_STR_PrescribedMinPressure; +extern const char * CS_STR_PrescribedMaxPressure; +extern const char * CS_STR_UntreatedAHI; +extern const char * CS_STR_Notes; +extern const char * CS_STR_DateDiagnosed; + +/*! \class CPAPSettings + \brief Profile Options relating to the CPAP settings + */ +class CPAPSettings +{ +public: + //! \brief Create CPAPSettings object given Profile *p, and initialize the defaults + CPAPSettings(Profile *p) :m_profile(p) + { + if (m_profile->contains(CS_STR_ComplianceHours)) (*m_profile)[CS_STR_ComplianceHours]=4; + if (m_profile->contains(CS_STR_ShowCompliance)) (*m_profile)[CS_STR_ShowCompliance]=true; + if (m_profile->contains(CS_STR_ShowLeaksMode)) (*m_profile)[CS_STR_ShowLeaksMode]=0; + // TODO: Check if this date is initiliazed yet + if (m_profile->contains(CS_STR_MaskStartDate)) (*m_profile)[CS_STR_MaskStartDate]=m_profile->FirstDay(); + if (m_profile->contains(CS_STR_MaskDescription)) (*m_profile)[CS_STR_MaskDescription]=QString(); + if (m_profile->contains(CS_STR_MaskType)) (*m_profile)[CS_STR_MaskType]=Mask_Unknown; + if (m_profile->contains(CS_STR_PrescribedMode)) (*m_profile)[CS_STR_PrescribedMode]=MODE_UNKNOWN; + if (m_profile->contains(CS_STR_PrescribedMinPressure)) (*m_profile)[CS_STR_PrescribedMinPressure]=0.0; + if (m_profile->contains(CS_STR_PrescribedMaxPressure)) (*m_profile)[CS_STR_PrescribedMaxPressure]=0.0; + if (m_profile->contains(CS_STR_UntreatedAHI)) (*m_profile)[CS_STR_UntreatedAHI]=0.0; + if (m_profile->contains(CS_STR_Notes)) (*m_profile)[CS_STR_Notes]=QString(); + if (m_profile->contains(CS_STR_DateDiagnosed)) (*m_profile)[CS_STR_DateDiagnosed]=PROFILE.FirstDay(); + } + + ~CPAPSettings() {} + + void setProfile(Profile *p) { m_profile=p; } + + double complianceHours() { return (*m_profile)[CS_STR_ComplianceHours].toDouble(); } + bool showComplianceInfo() { return (*m_profile)[CS_STR_ShowCompliance].toBool(); } + int leakMode() { return (*m_profile)[CS_STR_ShowLeaksMode].toInt(); } + QDate maskStartDate() { return (*m_profile)[CS_STR_MaskStartDate].toDate(); } + QString maskDescription() { return (*m_profile)[CS_STR_MaskDescription].toString(); } + MaskType maskType() { return (MaskType)(*m_profile)[CS_STR_MaskType].toInt(); } + CPAPMode mode() { return CPAPMode((*m_profile)[CS_STR_PrescribedMode].toInt()); } + double minPressure() { return (*m_profile)[CS_STR_PrescribedMinPressure].toDouble(); } + double maxPressure() { return (*m_profile)[CS_STR_PrescribedMaxPressure].toDouble(); } + double untreatedAHI() { return (*m_profile)[CS_STR_UntreatedAHI].toDouble(); } + const QString notes() { return (*m_profile)[CS_STR_Notes].toString(); } + QDate dateDiagnosed() { return (*m_profile)[CS_STR_DateDiagnosed].toDate(); } + + void setMode(CPAPMode mode) { (*m_profile)[CS_STR_PrescribedMode]=(int)mode; } + void setMinPressure(double pressure) { (*m_profile)[CS_STR_PrescribedMinPressure]=pressure; } + void setMaxPressure(double pressure) { (*m_profile)[CS_STR_PrescribedMaxPressure]=pressure; } + void setUntreatedAHI(double ahi) { (*m_profile)[CS_STR_UntreatedAHI]=ahi; } + void setNotes(QString notes) { (*m_profile)[CS_STR_Notes]=notes; } + void setDateDiagnosed(QDate date) { (*m_profile)[CS_STR_DateDiagnosed]=date; } + void setComplianceHours(double hours) { (*m_profile)[CS_STR_ComplianceHours]=hours; } + void setShowComplianceInfo(bool b) { (*m_profile)[CS_STR_ShowCompliance]=b; } + void setLeakMode(int leakmode) { (*m_profile)[CS_STR_ShowLeaksMode]=(int)leakmode; } + void setMaskStartDate(QDate date) { (*m_profile)[CS_STR_MaskStartDate]=date; } + void setMaskDescription(QString description) { (*m_profile)[CS_STR_MaskDescription]=description; } + void setMaskType(MaskType masktype) { (*m_profile)[CS_STR_MaskType]=(int)masktype; } + + Profile *m_profile; +}; + +extern const char * IS_STR_DaySplitTime; +extern const char * IS_STR_CacheSessions; +extern const char * IS_STR_CombineCloseSessions; +extern const char * IS_STR_IgnoreShorterSessions; +extern const char * IS_STR_Multithreading; + +/*! \class ImportSettings + \brief Profile Options relating to the Import process + */ +class ImportSettings +{ +public: + //! \brief Create ImportSettings object given Profile *p, and initialize the defaults + ImportSettings(Profile *p) :m_profile(p) + { + if (m_profile->contains(IS_STR_DaySplitTime)) (*m_profile)[IS_STR_DaySplitTime]=QTime(12,0,0); + if (m_profile->contains(IS_STR_CacheSessions)) (*m_profile)[IS_STR_CacheSessions]=false; + if (m_profile->contains(IS_STR_CombineCloseSessions)) (*m_profile)[IS_STR_CombineCloseSessions]=240; + if (m_profile->contains(IS_STR_IgnoreShorterSessions)) (*m_profile)[IS_STR_IgnoreShorterSessions]=5; + if (m_profile->contains(IS_STR_Multithreading)) (*m_profile)[IS_STR_Multithreading]=QThread::idealThreadCount() > 1; + } + ~ImportSettings() {} + + void setProfile(Profile *p) { m_profile=p; } + + QTime daySplitTime() { return (*m_profile)[IS_STR_DaySplitTime].toTime(); } + bool cacheSessions() { return (*m_profile)[IS_STR_CacheSessions].toBool(); } + double combineCloseSessions() { return (*m_profile)[IS_STR_CombineCloseSessions].toDouble(); } + double ignoreShortSessions() { return (*m_profile)[IS_STR_IgnoreShorterSessions].toDouble(); } + bool multithreading() { return (*m_profile)[IS_STR_Multithreading].toBool(); } + + void setDaySplitTime(QTime time) { (*m_profile)[IS_STR_DaySplitTime]=time; } + void setCacheSessions(bool c) { (*m_profile)[IS_STR_CacheSessions]=c; } + void setCombineCloseSessions(double val) { (*m_profile)[IS_STR_CombineCloseSessions]=val; } + void setIgnoreShortSessions(double val) { (*m_profile)[IS_STR_IgnoreShorterSessions]=val; } + void setMultithreading(bool enabled) { (*m_profile)[IS_STR_Multithreading]=enabled; } + + Profile *m_profile; +}; + +extern const char * AS_STR_GraphHeight; +extern const char * AS_STR_AntiAliasing; +extern const char * AS_STR_HighResPrinting; +extern const char * AS_STR_GraphSnapshots; +extern const char * AS_STR_Animations; +extern const char * AS_STR_SquareWave; +extern const char * AS_STR_OverlayType; + +/*! \class AppearanceSettings + \brief Profile Options relating to Visual Appearance + */ +class AppearanceSettings +{ +public: + //! \brief Create AppearanceSettings object given Profile *p, and initialize the defaults + AppearanceSettings(Profile *p) :m_profile(p) + { + if (m_profile->contains(AS_STR_GraphHeight)) (*m_profile)[AS_STR_GraphHeight]=180.0; + if (m_profile->contains(AS_STR_AntiAliasing)) (*m_profile)[AS_STR_AntiAliasing]=false; // i think it's ugly + if (m_profile->contains(AS_STR_HighResPrinting)) (*m_profile)[AS_STR_HighResPrinting]=true; + if (m_profile->contains(AS_STR_GraphSnapshots)) (*m_profile)[AS_STR_GraphSnapshots]=true; + if (m_profile->contains(AS_STR_Animations)) (*m_profile)[AS_STR_Animations]=true; + if (m_profile->contains(AS_STR_SquareWave)) (*m_profile)[AS_STR_SquareWave]=false; + if (m_profile->contains(AS_STR_OverlayType)) (*m_profile)[AS_STR_OverlayType]=ODT_Bars; + } + ~AppearanceSettings() {} + + void setProfile(Profile *p) { m_profile=p; } + + //! \brief Returns the normal (unscaled) height of a graph + int graphHeight() { return (*m_profile)[AS_STR_GraphHeight].toInt(); } + //! \brief Returns true if AntiAliasing (the graphical smoothing method) is enabled + bool antiAliasing() { return (*m_profile)[AS_STR_AntiAliasing].toBool(); } + //! \brief Returns true if QPrinter object should use higher-quality High Resolution print mode + bool highResPrinting() { return (*m_profile)[AS_STR_HighResPrinting].toBool(); } + //! \brief Returns true if renderPixmap function is in use, which takes snapshots of graphs + bool graphSnapshots() { return (*m_profile)[AS_STR_GraphSnapshots].toBool(); } + //! \brief Returns true if Graphical animations & Transitions will be drawn + bool animations() { return (*m_profile)[AS_STR_Animations].toBool(); } + //! \brief Returns true if Square Wave plots are preferred (where possible) + bool squareWavePlots() { return (*m_profile)[AS_STR_SquareWave].toBool(); } + //! \brief Returns the type of overlay flags (which are displayed over the Flow Waveform) + OverlayDisplayType overlayType() { return (OverlayDisplayType )(*m_profile)[AS_STR_OverlayType].toInt(); } + + //! \brief Set the normal (unscaled) height of a graph. + void setGraphHeight(int height) { (*m_profile)[AS_STR_GraphHeight]=height; } + //! \brief Set to true to turn on AntiAliasing (the graphical smoothing method) + void setAntiAliasing(bool aa) { (*m_profile)[AS_STR_AntiAliasing]=aa; } + //! \brief Set to true if QPrinter object should use higher-quality High Resolution print mode + void setHighResPrinting(bool hires) { (*m_profile)[AS_STR_HighResPrinting]=hires; } + //! \brief Set to true if renderPixmap functions are in use, which takes snapshots of graphs. + void setGraphSnapshots(bool gs) { (*m_profile)[AS_STR_GraphSnapshots]=gs; } + //! \brief Set to true if Graphical animations & Transitions will be drawn + void setAnimations(bool anim) { (*m_profile)[AS_STR_Animations]=anim; } + //! \brief Set whether or not to useSquare Wave plots (where possible) + void setSquareWavePlots(bool sw) { (*m_profile)[AS_STR_SquareWave]=sw; } + //! \brief Sets the type of overlay flags (which are displayed over the Flow Waveform) + void setOverlayType(OverlayDisplayType od) { (*m_profile)[AS_STR_OverlayType]=(int)od; } + + Profile *m_profile; +}; + + +extern const char * US_STR_UnitSystem; +extern const char * US_STR_EventWindowSize; +extern const char * US_STR_SkipEmptyDays; +extern const char * US_STR_RebuildCache; +extern const char * US_STR_TrashDayCache; +extern const char * US_STR_ShowDebug; +extern const char * US_STR_LinkGroups; + +/*! \class UserSettings + \brief Profile Options relating to General User Settings + */ +class UserSettings +{ +public: + //! \brief Create UserSettings object given Profile *p, and initialize the defaults + UserSettings(Profile *p) :m_profile(p) + { + if (m_profile->contains(US_STR_UnitSystem)) (*m_profile)[US_STR_UnitSystem]=US_Metric; + if (m_profile->contains(US_STR_EventWindowSize)) (*m_profile)[US_STR_EventWindowSize]=4.0; + if (m_profile->contains(US_STR_SkipEmptyDays)) (*m_profile)[US_STR_SkipEmptyDays]=true; + if (m_profile->contains(US_STR_RebuildCache)) (*m_profile)[US_STR_RebuildCache]=false; // can't remember.. + if (m_profile->contains(US_STR_TrashDayCache)) (*m_profile)[US_STR_TrashDayCache]=false; // can't remember.. + if (m_profile->contains(US_STR_ShowDebug)) (*m_profile)[US_STR_ShowDebug]=false; + if (m_profile->contains(US_STR_LinkGroups)) (*m_profile)[US_STR_LinkGroups]=true; // can't remember.. + } + ~UserSettings() {} + + void setProfile(Profile *p) { m_profile=p; } + + UnitSystem unitSystem() { return (UnitSystem)(*m_profile)[US_STR_UnitSystem].toInt(); } + double eventWindowSize() { return (*m_profile)[US_STR_EventWindowSize].toDouble(); } + bool skipEmptyDays() { return (*m_profile)[US_STR_SkipEmptyDays].toBool(); } + bool rebuildCache() { return (*m_profile)[US_STR_RebuildCache].toBool(); } + bool trashDayCache() { return (*m_profile)[US_STR_TrashDayCache].toBool(); } + bool showDebug() { return (*m_profile)[US_STR_ShowDebug].toBool(); } + bool linkGroups() { return (*m_profile)[US_STR_LinkGroups].toBool(); } + + void setUnitSystem(UnitSystem us) { (*m_profile)[US_STR_UnitSystem]=(int)us; } + void setEventWindowSize(double size) { (*m_profile)[US_STR_EventWindowSize]=size; } + void setSkipEmptyDays(bool skip) { (*m_profile)[US_STR_SkipEmptyDays]=skip; } + void setRebuildCache(bool rebuild) { (*m_profile)[US_STR_RebuildCache]=rebuild; } + void setTrashDayCache(bool trash) { (*m_profile)[US_STR_TrashDayCache]=trash; } + void setShowDebug(bool b) { (*m_profile)[US_STR_ShowDebug]=b; } + void setLinkGroups(bool link) { (*m_profile)[US_STR_LinkGroups]=link; } + + Profile *m_profile; +}; + + namespace Profiles { @@ -111,7 +535,7 @@ Profile *Create(QString name); Profile *Get(QString name); Profile *Get(); -}; +} #endif //PROFILES_H diff --git a/SleepyHeadQT.pro b/SleepyHeadQT.pro index d9274d79..29d3acfc 100644 --- a/SleepyHeadQT.pro +++ b/SleepyHeadQT.pro @@ -155,7 +155,8 @@ HEADERS += \ quazip/JlCompress.h \ quazip/ioapi.h \ quazip/crypt.h \ - UpdaterWindow.h + UpdaterWindow.h \ + SleepLib/common.h FORMS += \ diff --git a/daily.cpp b/daily.cpp index d524fad7..388326ca 100644 --- a/daily.cpp +++ b/daily.cpp @@ -89,30 +89,30 @@ Daily::Daily(QWidget *parent,gGraphView * shared) layout->addWidget(scrollbar,0); int default_height=PROFILE["GraphHeight"].toInt(); - SF=new gGraph(GraphView,"Event Flags","Event Flags",default_height); - FRW=new gGraph(GraphView,schema::channel[CPAP_FlowRate].label(),schema::channel[CPAP_FlowRate].description()+"\n("+schema::channel[CPAP_FlowRate].units()+")",default_height); - AHI=new gGraph(GraphView,schema::channel[CPAP_AHI].label(),schema::channel[CPAP_AHI].description()+"\n("+schema::channel[CPAP_AHI].units()+")",default_height); - MP=new gGraph(GraphView,schema::channel[CPAP_MaskPressure].label(),schema::channel[CPAP_MaskPressure].description()+"\n("+schema::channel[CPAP_MaskPressure].units()+")",default_height); - PRD=new gGraph(GraphView,schema::channel[CPAP_Pressure].label(),schema::channel[CPAP_Pressure].description()+"\n("+schema::channel[CPAP_Pressure].units()+")",default_height); - LEAK=new gGraph(GraphView,schema::channel[CPAP_Leak].label(),schema::channel[CPAP_Leak].description()+"\n("+schema::channel[CPAP_Leak].units()+")",default_height); - SNORE=new gGraph(GraphView,schema::channel[CPAP_Snore].label(),schema::channel[CPAP_Snore].description()+"\n("+schema::channel[CPAP_Snore].units()+")",default_height); - RR=new gGraph(GraphView,schema::channel[CPAP_RespRate].label(),schema::channel[CPAP_RespRate].description()+"\n("+schema::channel[CPAP_RespRate].units()+")",default_height); - TV=new gGraph(GraphView,schema::channel[CPAP_TidalVolume].label(),schema::channel[CPAP_TidalVolume].description()+"\n("+schema::channel[CPAP_TidalVolume].units()+")",default_height); - MV=new gGraph(GraphView,schema::channel[CPAP_MinuteVent].label(),schema::channel[CPAP_MinuteVent].description()+"\n("+schema::channel[CPAP_MinuteVent].units()+")",default_height); - FLG=new gGraph(GraphView,schema::channel[CPAP_FLG].label(),schema::channel[CPAP_FLG].description()+"\n("+schema::channel[CPAP_FLG].units()+")",default_height); - PTB=new gGraph(GraphView,schema::channel[CPAP_PTB].label(),schema::channel[CPAP_PTB].description()+"\n("+schema::channel[CPAP_PTB].units()+")",default_height); - RE=new gGraph(GraphView,schema::channel[CPAP_RespEvent].label(),schema::channel[CPAP_RespEvent].description()+"\n("+schema::channel[CPAP_RespEvent].units()+")",default_height); - IE=new gGraph(GraphView,schema::channel[CPAP_IE].label(),schema::channel[CPAP_IE].description()+"\n("+schema::channel[CPAP_IE].units()+")",default_height); - TE=new gGraph(GraphView,schema::channel[CPAP_Te].label(),schema::channel[CPAP_Te].description()+"\n("+schema::channel[CPAP_Te].units()+")",default_height); - TI=new gGraph(GraphView,schema::channel[CPAP_Ti].label(),schema::channel[CPAP_Ti].description()+"\n("+schema::channel[CPAP_Ti].units()+")",default_height); - TgMV=new gGraph(GraphView,schema::channel[CPAP_TgMV].label(),schema::channel[CPAP_TgMV].description()+"\n("+schema::channel[CPAP_TgMV].units()+")",default_height); + SF=new gGraph(GraphView,tr("Event Flags"),tr("Event Flags"),default_height); + FRW=new gGraph(GraphView,tr("Flow Rate"),schema::channel[CPAP_FlowRate].description()+"\n("+schema::channel[CPAP_FlowRate].units()+")",default_height); + AHI=new gGraph(GraphView,tr("AHI"),schema::channel[CPAP_AHI].description()+"\n("+schema::channel[CPAP_AHI].units()+")",default_height); + MP=new gGraph(GraphView,tr("Mask Pressure"),schema::channel[CPAP_MaskPressure].description()+"\n("+schema::channel[CPAP_MaskPressure].units()+")",default_height); + PRD=new gGraph(GraphView,tr("Pressure"),schema::channel[CPAP_Pressure].description()+"\n("+schema::channel[CPAP_Pressure].units()+")",default_height); + LEAK=new gGraph(GraphView,tr("Leak"),schema::channel[CPAP_Leak].description()+"\n("+schema::channel[CPAP_Leak].units()+")",default_height); + SNORE=new gGraph(GraphView,tr("Snore"),schema::channel[CPAP_Snore].description()+"\n("+schema::channel[CPAP_Snore].units()+")",default_height); + RR=new gGraph(GraphView,tr("Resp. Rate"),schema::channel[CPAP_RespRate].description()+"\n("+schema::channel[CPAP_RespRate].units()+")",default_height); + TV=new gGraph(GraphView,tr("Tidal Volume"),schema::channel[CPAP_TidalVolume].description()+"\n("+schema::channel[CPAP_TidalVolume].units()+")",default_height); + MV=new gGraph(GraphView,tr("Minute Vent."),schema::channel[CPAP_MinuteVent].description()+"\n("+schema::channel[CPAP_MinuteVent].units()+")",default_height); + FLG=new gGraph(GraphView,tr("Flow Limitation"),schema::channel[CPAP_FLG].description()+"\n("+schema::channel[CPAP_FLG].units()+")",default_height); + PTB=new gGraph(GraphView,tr("Pat. Trig. Breath"),schema::channel[CPAP_PTB].description()+"\n("+schema::channel[CPAP_PTB].units()+")",default_height); + RE=new gGraph(GraphView,tr("Resp. Event"),schema::channel[CPAP_RespEvent].description()+"\n("+schema::channel[CPAP_RespEvent].units()+")",default_height); + IE=new gGraph(GraphView,tr("IE"),schema::channel[CPAP_IE].description()+"\n("+schema::channel[CPAP_IE].units()+")",default_height); + TE=new gGraph(GraphView,tr("Te"),schema::channel[CPAP_Te].description()+"\n("+schema::channel[CPAP_Te].units()+")",default_height); + TI=new gGraph(GraphView,tr("Ti"),schema::channel[CPAP_Ti].description()+"\n("+schema::channel[CPAP_Ti].units()+")",default_height); + TgMV=new gGraph(GraphView,tr("Tgt. Min. Vent"),schema::channel[CPAP_TgMV].description()+"\n("+schema::channel[CPAP_TgMV].units()+")",default_height); //INTPULSE=new gGraph(GraphView,"R-Pulse",schema::channel[CPAP_Te].units(),default_height); //INTSPO2=new gGraph(GraphView,"R-SPO2",default_height); int oxigrp=PROFILE.ExistsAndTrue("SyncOximetry") ? 0 : 1; - PULSE=new gGraph(GraphView,schema::channel[OXI_Pulse].label(),schema::channel[OXI_Pulse].description()+"\n("+schema::channel[OXI_Pulse].units()+")",default_height,oxigrp); - SPO2=new gGraph(GraphView,schema::channel[OXI_SPO2].label(),schema::channel[OXI_SPO2].description()+"\n("+schema::channel[OXI_SPO2].units()+")",default_height,oxigrp); - PLETHY=new gGraph(GraphView,schema::channel[OXI_Plethy].label(),schema::channel[OXI_Plethy].description()+"\n("+schema::channel[OXI_Plethy].units()+")",default_height,oxigrp); + PULSE=new gGraph(GraphView,tr("Pulse"),schema::channel[OXI_Pulse].description()+"\n("+schema::channel[OXI_Pulse].units()+")",default_height,oxigrp); + SPO2=new gGraph(GraphView,tr("SpO2"),schema::channel[OXI_SPO2].description()+"\n("+schema::channel[OXI_SPO2].units()+")",default_height,oxigrp); + PLETHY=new gGraph(GraphView,tr("Plethy"),schema::channel[OXI_Plethy].description()+"\n("+schema::channel[OXI_Plethy].units()+")",default_height,oxigrp); // Event Pie Chart (for snapshot purposes) // TODO: Convert snapGV to generic for snapshotting multiple graphs (like reports does) @@ -123,14 +123,14 @@ Daily::Daily(QWidget *parent,gGraphView * shared) //TAP->setMargins(0,0,0,0); - GAHI=new gGraph(snapGV,"Breakdown","events",172); + GAHI=new gGraph(snapGV,tr("Breakdown"),tr("events"),172); gSegmentChart * evseg=new gSegmentChart(GST_Pie); - evseg->AddSlice(CPAP_Hypopnea,QColor(0x40,0x40,0xff,0xff),"H"); - evseg->AddSlice(CPAP_Apnea,QColor(0x20,0x80,0x20,0xff),"A"); - evseg->AddSlice(CPAP_Obstructive,QColor(0x40,0xaf,0xbf,0xff),"OA"); - evseg->AddSlice(CPAP_ClearAirway,QColor(0xb2,0x54,0xcd,0xff),"CA"); - evseg->AddSlice(CPAP_RERA,QColor(0xff,0xff,0x80,0xff),"RE"); - evseg->AddSlice(CPAP_FlowLimit,QColor(0x40,0x40,0x40,0xff),"FL"); + evseg->AddSlice(CPAP_Hypopnea,QColor(0x40,0x40,0xff,0xff),tr("H")); + evseg->AddSlice(CPAP_Apnea,QColor(0x20,0x80,0x20,0xff),tr("A")); + evseg->AddSlice(CPAP_Obstructive,QColor(0x40,0xaf,0xbf,0xff),tr("OA")); + evseg->AddSlice(CPAP_ClearAirway,QColor(0xb2,0x54,0xcd,0xff),tr("CA")); + evseg->AddSlice(CPAP_RERA,QColor(0xff,0xff,0x80,0xff),tr("RE")); + evseg->AddSlice(CPAP_FlowLimit,QColor(0x40,0x40,0x40,0xff),tr("FL")); GAHI->AddLayer(AddCPAP(evseg)); GAHI->setMargins(0,0,0,0); @@ -138,21 +138,21 @@ Daily::Daily(QWidget *parent,gGraphView * shared) gFlagsGroup *fg=new gFlagsGroup(); SF->AddLayer(AddCPAP(fg)); - fg->AddLayer((new gFlagsLine(CPAP_CSR,QColor("light green"),"PB",false,FT_Span))); - fg->AddLayer((new gFlagsLine(CPAP_ClearAirway,QColor("purple"),"CA",false))); - fg->AddLayer((new gFlagsLine(CPAP_Obstructive,QColor("#40c0ff"),"OA",true))); - fg->AddLayer((new gFlagsLine(CPAP_Apnea,QColor("dark green"),"A"))); - fg->AddLayer((new gFlagsLine(CPAP_Hypopnea,QColor("blue"),"H",true))); - fg->AddLayer((new gFlagsLine(CPAP_ExP,QColor("dark cyan"),"E",false))); - fg->AddLayer((new gFlagsLine(CPAP_LeakFlag,QColor("dark blue"),"L",false))); - fg->AddLayer((new gFlagsLine(CPAP_NRI,QColor("dark magenta"),"NRI",false))); - fg->AddLayer((new gFlagsLine(CPAP_FlowLimit,QColor("black"),"FL"))); - fg->AddLayer((new gFlagsLine(CPAP_RERA,QColor("gold"),"RE"))); - fg->AddLayer((new gFlagsLine(CPAP_VSnore,QColor("red"),"VS"))); - fg->AddLayer((new gFlagsLine("UserFlag1",QColor("yellow"),"UF1"))); - fg->AddLayer((new gFlagsLine("UserFlag2",QColor("green"),"UF2"))); - //fg->AddLayer((new gFlagsLine(PRS1_0B,QColor("dark green"),"U0B"))); - //fg->AddLayer((new gFlagsLine(CPAP_VSnore2,QColor("red"),"VS2"))); + fg->AddLayer((new gFlagsLine(CPAP_CSR,QColor("light green"),tr("PB"),false,FT_Span))); + fg->AddLayer((new gFlagsLine(CPAP_ClearAirway,QColor("purple"),tr("CA"),false))); + fg->AddLayer((new gFlagsLine(CPAP_Obstructive,QColor("#40c0ff"),tr("OA"),true))); + fg->AddLayer((new gFlagsLine(CPAP_Apnea,QColor("dark green"),tr("A")))); + fg->AddLayer((new gFlagsLine(CPAP_Hypopnea,QColor("blue"),tr("H"),true))); + fg->AddLayer((new gFlagsLine(CPAP_ExP,QColor("dark cyan"),tr("E"),false))); + fg->AddLayer((new gFlagsLine(CPAP_LeakFlag,QColor("dark blue"),tr("L"),false))); + fg->AddLayer((new gFlagsLine(CPAP_NRI,QColor("dark magenta"),tr("NRI"),false))); + fg->AddLayer((new gFlagsLine(CPAP_FlowLimit,QColor("black"),tr("FL")))); + fg->AddLayer((new gFlagsLine(CPAP_RERA,QColor("gold"),tr("RE")))); + fg->AddLayer((new gFlagsLine(CPAP_VSnore,QColor("red"),tr("VS")))); + fg->AddLayer((new gFlagsLine("UserFlag1",QColor("yellow"),tr("UF1")))); + fg->AddLayer((new gFlagsLine("UserFlag2",QColor("green"),tr("UF2")))); + //fg->AddLayer((new gFlagsLine(PRS1_0B,QColor("dark green"),tr("U0B")))); + //fg->AddLayer((new gFlagsLine(CPAP_VSnore2,QColor("red"),tr("VS2")))); SF->setBlockZoom(true); SF->AddLayer(new gShadowArea()); SF->AddLayer(new gYSpacer(),LayerLeft,gYAxis::Margin); @@ -162,29 +162,29 @@ Daily::Daily(QWidget *parent,gGraphView * shared) gLineChart *l; l=new gLineChart(CPAP_FlowRate,Qt::black,false,false); - gLineOverlaySummary *los=new gLineOverlaySummary("Selection AHI",5,-4); + gLineOverlaySummary *los=new gLineOverlaySummary(tr("Selection AHI"),5,-4); AddCPAP(l); FRW->AddLayer(new gXGrid()); - FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_CSR,QColor("light green"),"CSR",FT_Span))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_CSR,QColor("light green"),tr("CSR"),FT_Span))); FRW->AddLayer(l); FRW->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); FRW->AddLayer(new gXAxis(),LayerBottom,0,20); - FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Hypopnea,QColor("blue"),"H")))); - FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_PressurePulse,QColor("red"),"PR",FT_Dot))); - //FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Pressure,QColor("white"),"P",FT_Dot))); + FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Hypopnea,QColor("blue"),tr("H"))))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_PressurePulse,QColor("red"),tr("PR"),FT_Dot))); + //FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_Pressure,QColor("white"),tr("P"),FT_Dot))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_0B,QColor("blue"),"0B",FT_Dot))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_10,QColor("orange"),"10",FT_Dot))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_0E,QColor("dark red"),"0E",FT_Dot))); - FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_RERA,QColor("gold"),"RE"))); - FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Apnea,QColor("dark green"),"A")))); - FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_VSnore,QColor("red"),"VS"))); - FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_FlowLimit,QColor("black"),"FL"))); - FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Obstructive,QColor("#40c0ff"),"OA")))); - FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_ClearAirway,QColor("purple"),"CA")))); - FRW->AddLayer(AddCPAP(new gLineOverlayBar("UserFlag1",QColor("yellow"),"U1",FT_Bar))); - FRW->AddLayer(AddCPAP(new gLineOverlayBar("UserFlag2",QColor("orange"),"U2",FT_Bar))); - FRW->AddLayer(AddOXI(new gLineOverlayBar(OXI_SPO2Drop,QColor("red"),"O2"))); - FRW->AddLayer(AddOXI(new gLineOverlayBar(OXI_PulseChange,QColor("blue"),"PC",FT_Dot))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_RERA,QColor("gold"),tr("RE")))); + FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Apnea,QColor("dark green"),tr("A"))))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_VSnore,QColor("red"),tr("VS")))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_FlowLimit,QColor("black"),tr("FL")))); + FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Obstructive,QColor("#40c0ff"),tr("OA"))))); + FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_ClearAirway,QColor("purple"),tr("CA"))))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar("UserFlag1",QColor("yellow"),tr("U1"),FT_Bar))); + FRW->AddLayer(AddCPAP(new gLineOverlayBar("UserFlag2",QColor("orange"),tr("U2"),FT_Bar))); + FRW->AddLayer(AddOXI(new gLineOverlayBar(OXI_SPO2Drop,QColor("red"),tr("O2")))); + FRW->AddLayer(AddOXI(new gLineOverlayBar(OXI_PulseChange,QColor("blue"),tr("PC"),FT_Dot))); FRW->AddLayer(AddCPAP(los)); @@ -239,8 +239,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared) //INTPULSE->AddLayer(AddCPAP(new gLineChart(OXI_Pulse,Qt::red,square))); //INTSPO2->AddLayer(AddCPAP(new gLineChart(OXI_SPO2,Qt::blue,square))); - PULSE->AddLayer(AddOXI(new gLineOverlayBar(OXI_PulseChange,QColor("light gray"),"PD",FT_Span))); - SPO2->AddLayer(AddOXI(new gLineOverlayBar(OXI_SPO2Drop,QColor("light blue"),"O2",FT_Span))); + PULSE->AddLayer(AddOXI(new gLineOverlayBar(OXI_PulseChange,QColor("light gray"),tr("PD"),FT_Span))); + SPO2->AddLayer(AddOXI(new gLineOverlayBar(OXI_SPO2Drop,QColor("light blue"),tr("O2"),FT_Span))); PULSE->AddLayer(AddOXI(new gLineChart(OXI_Pulse,Qt::red,square))); SPO2->AddLayer(AddOXI(new gLineChart(OXI_SPO2,Qt::blue,true))); @@ -294,7 +294,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) QPushButton *btn=new QPushButton(title,this); btn->setCheckable(true); btn->setChecked((*GraphView)[i]->visible()); - btn->setToolTip("Show/Hide "+title); + btn->setToolTip(tr("Show/Hide %1").arg(title)); GraphToggles[title]=btn; btn->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum); ui->graphToggleArea->addWidget(btn); @@ -305,15 +305,16 @@ Daily::Daily(QWidget *parent,gGraphView * shared) // TODO: Add preference to hide do this for Widget Haters.. //ui->calNavWidget->hide(); - if (PROFILE["Units"].toString()=="metric") { - ui->ouncesSpinBox->setVisible(false); - ui->weightSpinBox->setDecimals(3); - ui->weightSpinBox->setSuffix("Kg"); - } else { - ui->weightSpinBox->setSuffix("lb"); + + if (unitSystem()==US_Archiac) { + ui->weightSpinBox->setSuffix(tr("lb")); ui->weightSpinBox->setDecimals(0); ui->ouncesSpinBox->setVisible(true); - ui->ouncesSpinBox->setSuffix("oz"); + ui->ouncesSpinBox->setSuffix(tr("oz")); + } else { + ui->ouncesSpinBox->setVisible(false); + ui->weightSpinBox->setDecimals(3); + ui->weightSpinBox->setSuffix(tr("Kg")); } } @@ -423,7 +424,8 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) && (code!=CPAP_ClearAirway) && (code!=CPAP_CSR) && (code!=CPAP_RERA) - && (code!="UserFlag1") + && (code!=CPAP_UserFlag1) + && (code!=CPAP_UserFlag2) && (code!=CPAP_NRI) && (code!=CPAP_LeakFlag) && (code!=CPAP_ExP) @@ -436,9 +438,12 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day) total_events+=cnt; QString st=schema::channel[code].description(); if (st.isEmpty()) { - st="Fixme "+code; + st="Fixme %1"+code; } - st+=" ("+QString::number(cnt)+" event"+((cnt>1)?"s":"")+")"; + st+=" "; + if (cnt==1) st+=tr("%1 event").arg(cnt); + else st+=tr("%1 events").arg(cnt); + QStringList l(st); l.append(""); mcroot[code]=mcr=new QTreeWidgetItem(root,l); @@ -535,15 +540,15 @@ void Daily::on_calendar_selectionChanged() ui->calButton->setText(ui->calendar->selectedDate().toString(Qt::TextDate)); ui->calendar->setFocus(Qt::ActiveWindowFocusReason); - if (PROFILE["Units"].toString()=="metric") { - ui->ouncesSpinBox->setVisible(false); - ui->weightSpinBox->setDecimals(3); - ui->weightSpinBox->setSuffix("Kg"); - } else { - ui->weightSpinBox->setSuffix("lb"); + if (unitSystem()==US_Archiac) { + ui->weightSpinBox->setSuffix(tr("lb")); ui->weightSpinBox->setDecimals(0); ui->ouncesSpinBox->setVisible(true); - ui->ouncesSpinBox->setSuffix("oz"); + ui->ouncesSpinBox->setSuffix(tr("oz")); + } else { + ui->ouncesSpinBox->setVisible(false); + ui->weightSpinBox->setDecimals(3); + ui->weightSpinBox->setSuffix(tr("Kg")); } } void Daily::ResetGraphLayout() @@ -959,13 +964,14 @@ void Daily::Load(QDate date) if (journal->settings.contains(Journal_Weight)) { double kg=journal->settings[Journal_Weight].toDouble(&ok); - if (PROFILE["Units"].toString()=="metric") { + + if (unitSystem()==US_Metric) { ui->weightSpinBox->setDecimals(3); ui->weightSpinBox->blockSignals(true); ui->weightSpinBox->setValue(kg); ui->weightSpinBox->blockSignals(false); ui->ouncesSpinBox->setVisible(false); - ui->weightSpinBox->setSuffix("Kg"); + ui->weightSpinBox->setSuffix(tr("Kg")); } else { float ounces=(kg*1000.0)/ounce_convert; int pounds=ounces/16.0; @@ -979,10 +985,10 @@ void Daily::Load(QDate date) ui->ouncesSpinBox->blockSignals(false); ui->weightSpinBox->blockSignals(false); - ui->weightSpinBox->setSuffix("lb"); + ui->weightSpinBox->setSuffix(tr("lb")); ui->weightSpinBox->setDecimals(0); ui->ouncesSpinBox->setVisible(true); - ui->ouncesSpinBox->setSuffix("oz"); + ui->ouncesSpinBox->setSuffix(tr("oz")); } double height=PROFILE["Height"].toDouble(&ok)/100.0; if (height>0 && kg>0) { @@ -1032,7 +1038,7 @@ void Daily::Load(QDate date) void Daily::UnitsChanged() { double kg; - if (PROFILE["Units"].toString()!="metric") { + if (unitSystem(true)==US_Metric) { kg=ui->weightSpinBox->value(); float ounces=(kg*1000.0)/ounce_convert; int pounds=ounces/16; @@ -1237,7 +1243,7 @@ void Daily::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column) double st=qint64((d.addSecs(-(winsize/2))).toTime_t())*1000L; double et=qint64((d.addSecs(winsize/2)).toTime_t())*1000L; - gGraph *g=GraphView->findGraph("Event Flags"); + gGraph *g=GraphView->findGraph(tr("Event Flags")); if (!g) return; if (strmin_x) { st=g->rmin_x; @@ -1453,10 +1459,10 @@ void Daily::on_weightSpinBox_valueChanged(double arg1) } double kg; - if (PROFILE["Units"].toString()=="metric") - kg=arg1; - else { - kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert); + if (unitSystem()==US_Archiac) { + kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert); + } else { + kg=arg1; } journal->settings[Journal_Weight]=kg; gGraphView *gv=mainwin->getOverview()->graphView(); diff --git a/overview.cpp b/overview.cpp index 28be9827..b409ca45 100644 --- a/overview.cpp +++ b/overview.cpp @@ -243,9 +243,7 @@ gGraph * Overview::createGraph(QString name,QString units, YTickerType yttype) yt=new gYAxisTime(true); // Time scale break; case YT_Weight: - if (PROFILE["Units"].toString()=="metric") { - yt=new gYAxisWeight(US_Metric); - } else yt=new gYAxisWeight(US_Archiac); + yt=new gYAxisWeight(unitSystem()); break; default: yt=new gYAxis(); // Plain numeric scale