diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index 21124a48..e1ba9fc2 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -44,19 +44,19 @@ void InitGraphs() { if (!_graph_init) { - if (!PREF.Exists("Fonts_Graph_Name")) { + if (!PREF.contains("Fonts_Graph_Name")) { PREF["Fonts_Graph_Name"]="Sans Serif"; PREF["Fonts_Graph_Size"]=10; PREF["Fonts_Graph_Bold"]=false; PREF["Fonts_Graph_Italic"]=false; } - if (!PREF.Exists("Fonts_Title_Name")) { + if (!PREF.contains("Fonts_Title_Name")) { PREF["Fonts_Title_Name"]="Serif"; PREF["Fonts_Title_Size"]=11; PREF["Fonts_Title_Bold"]=true; PREF["Fonts_Title_Italic"]=false; } - if (!PREF.Exists("Fonts_Big_Name")) { + if (!PREF.contains("Fonts_Big_Name")) { PREF["Fonts_Big_Name"]="Serif"; PREF["Fonts_Big_Size"]=35; PREF["Fonts_Big_Bold"]=false; @@ -2518,7 +2518,7 @@ void gGraphView::paintGL() if (m_fadingOut) { // bindTexture(previous_day_snapshot); } else if (m_fadingIn) { - int offset,offset2; + //int offset,offset2; float aphase; aphase=1.0-phase; /*if (m_fadedir) { // forwards @@ -2532,7 +2532,7 @@ void gGraphView::paintGL() //offset=-width(); //offset2=0;//-width(); }*/ - offset=0; offset2=0; + //offset=0; offset2=0; glEnable(GL_BLEND); @@ -2733,7 +2733,7 @@ void gGraphView::mouseMoveEvent(QMouseEvent * event) m_graphs[i]->mouseMoveEvent(&e); if (!m_button_down && (x<=titleWidth+(gYAxis::Margin-5))) { //qDebug() << "Hovering over" << m_graphs[i]->title(); - if (m_graphsbytitle["Event Flags"]==m_graphs[i]) { + if (m_graphsbytitle[STR_TR_EventFlags]==m_graphs[i]) { QVector & layers=m_graphs[i]->layers(); gFlagsGroup *fg; for (int i=0;imachine()->GetType()!=MT_CPAP) return 0; - if (session->machine()->GetClass()!="PRS1") return 0; + if (session->machine()->GetClass()!=STR_MACH_PRS1) return 0; if (!session->eventlist.contains(CPAP_FlowRate)) return 0; //need flow waveform @@ -511,7 +511,6 @@ int calcPulseChange(Session *session) EventDataType val,val2,change,tmp; qint64 time,time2; - bool ok; qint64 window=PROFILE.oxi->pulseChangeDuration(); window*=1000; @@ -579,7 +578,6 @@ int calcSPO2Drop(Session *session) EventDataType val,val2,change,tmp; qint64 time,time2; - bool ok; qint64 window=PROFILE.oxi->spO2DropDuration(); window*=1000; change=PROFILE.oxi->spO2DropPercentage(); diff --git a/SleepLib/common.h b/SleepLib/common.h index 687ae1e3..356d3fa4 100644 --- a/SleepLib/common.h +++ b/SleepLib/common.h @@ -17,10 +17,43 @@ const QString STR_UNIT_FOOT=QObject::tr("ft"); const QString STR_UNIT_POUND=QObject::tr("lb"); const QString STR_UNIT_OUNCE=QObject::tr("oz"); const QString STR_UNIT_KG=QObject::tr("Kg"); +const QString STR_UNIT_CMH2O=QObject::tr("cmH2O"); +const QString STR_UNIT_Hours=QObject::tr("Hours"); const QString STR_MESSAGE_ERROR=QObject::tr("Error"); const QString STR_MESSAGE_WARNING=QObject::tr("Warning"); +const QString STR_GEN_Profile="Profile"; +const QString STR_GEN_SkipLogin="SkipLoginScreen"; +const QString STR_GEN_UpdatesLastChecked="UpdatesLastChecked"; +const QString STR_GEN_UpdatesAutoCheck="Updates_AutoCheck"; +const QString STR_GEN_UpdateCheckFrequency="Updates_CheckFrequency"; +const QString STR_GEN_DataFolder="DataFolder"; +const QString STR_GEN_On=QObject::tr("On"); +const QString STR_GEN_Off=QObject::tr("Off"); + +const QString STR_PROP_Brand="Brand"; +const QString STR_PROP_Model="Model"; +const QString STR_PROP_ModelNumber="ModelNumber"; +const QString STR_PROP_SubModel="SubModel"; +const QString STR_PROP_Serial="Serial"; +const QString STR_PROP_DataVersion="DataVersion"; + +const QString STR_MACH_ResMed="ResMed"; +const QString STR_MACH_PRS1="PRS1"; +const QString STR_MACH_Journal="Journal"; +const QString STR_MACH_Intellipap="Intellipap"; +const QString STR_MACH_CMS50="CMS50"; +const QString STR_MACH_ZEO="Zeo"; + +const QString STR_TR_BMI=QObject::tr("BMI"); +const QString STR_TR_Weight=QObject::tr("Weight"); + +const QString STR_TR_Daily=QObject::tr("Daily"); +const QString STR_TR_Overview=QObject::tr("Overview"); +const QString STR_TR_Oximetry=QObject::tr("Oximetry"); + +const QString STR_TR_EventFlags=QObject::tr("Event Flags"); #endif // COMMON_H diff --git a/SleepLib/loader_plugins/cms50_loader.cpp b/SleepLib/loader_plugins/cms50_loader.cpp index 39b20724..b0cd03f1 100644 --- a/SleepLib/loader_plugins/cms50_loader.cpp +++ b/SleepLib/loader_plugins/cms50_loader.cpp @@ -322,11 +322,11 @@ Machine *CMS50Loader::CreateMachine(Profile *profile) Machine *m=new Oximeter(profile,0); m->SetClass(cms50_class_name); - m->properties["Brand"]="Contec"; - m->properties["Model"]="CMS50X"; + m->properties[STR_PROP_Brand]="Contec"; + m->properties[STR_PROP_Model]="CMS50X"; QString a; a.sprintf("%i",cms50_data_version); - m->properties["DataVersion"]=a; + m->properties[STR_PROP_DataVersion]=a; profile->AddMachine(m); return m; diff --git a/SleepLib/loader_plugins/intellipap_loader.cpp b/SleepLib/loader_plugins/intellipap_loader.cpp index b0ca6107..4df195ef 100644 --- a/SleepLib/loader_plugins/intellipap_loader.cpp +++ b/SleepLib/loader_plugins/intellipap_loader.cpp @@ -21,8 +21,8 @@ Intellipap::Intellipap(Profile *p,MachineID id) :CPAP(p,id) { m_class=intellipap_class_name; - properties["Brand"]="DeVilbiss"; - properties["Model"]="Intellipap"; + properties[STR_PROP_Brand]="DeVilbiss"; + properties[STR_PROP_Model]=STR_MACH_Intellipap; } Intellipap::~Intellipap() @@ -67,8 +67,8 @@ int IntellipapLoader::Open(QString & path,Profile *profile) QTextStream tstream(&f); QHash lookup; - lookup["Sn"]="Serial"; - lookup["Mn"]="Model"; + lookup["Sn"]=STR_PROP_Serial; + lookup["Mn"]=STR_PROP_Model; lookup["Mo"]="PAPMode"; // 0=cpap, 1=auto //lookup["Pn"]="Pn"; lookup["Pu"]="MaxPressure"; @@ -125,8 +125,8 @@ int IntellipapLoader::Open(QString & path,Profile *profile) } Machine *mach=NULL; - if (set1.contains("Serial")) { - mach=CreateMachine(set1["Serial"],profile); + if (set1.contains(STR_PROP_Serial)) { + mach=CreateMachine(set1[STR_PROP_Serial],profile); } if (!mach) { qDebug() << "Couldn't get Intellipap machine record"; @@ -332,7 +332,7 @@ int IntellipapLoader::Open(QString & path,Profile *profile) }*/ } } - mach->properties["DataVersion"]=QString().sprintf("%i",intellipap_data_version); + mach->properties[STR_PROP_DataVersion]=QString().sprintf("%i",intellipap_data_version); mach->Save(); @@ -355,7 +355,7 @@ Machine *IntellipapLoader::CreateMachine(QString serial,Profile *profile) bool found=false; QList::iterator i; for (i=ml.begin(); i!=ml.end(); i++) { - if (((*i)->GetClass()==intellipap_class_name) && ((*i)->properties["Serial"]==serial)) { + if (((*i)->GetClass()==intellipap_class_name) && ((*i)->properties[STR_PROP_Serial]==serial)) { MachList[serial]=*i; //static_cast(*i); found=true; break; @@ -368,7 +368,7 @@ Machine *IntellipapLoader::CreateMachine(QString serial,Profile *profile) MachList[serial]=m; profile->AddMachine(m); - m->properties["Serial"]=serial; + m->properties[STR_PROP_Serial]=serial; return m; } diff --git a/SleepLib/loader_plugins/intellipap_loader.h b/SleepLib/loader_plugins/intellipap_loader.h index 85604f64..9a3e822c 100644 --- a/SleepLib/loader_plugins/intellipap_loader.h +++ b/SleepLib/loader_plugins/intellipap_loader.h @@ -36,7 +36,7 @@ public: const int intellipap_load_buffer_size=1024*1024; -const QString intellipap_class_name="Intellipap"; +const QString intellipap_class_name=STR_MACH_Intellipap; /*! \class IntellipapLoader \brief Loader for DeVilbiss Intellipap Auto data diff --git a/SleepLib/loader_plugins/prs1_loader.cpp b/SleepLib/loader_plugins/prs1_loader.cpp index 6a150b3a..3613c99e 100644 --- a/SleepLib/loader_plugins/prs1_loader.cpp +++ b/SleepLib/loader_plugins/prs1_loader.cpp @@ -96,8 +96,8 @@ crc_t CRC16(const unsigned char *data, size_t data_len) PRS1::PRS1(Profile *p,MachineID id):CPAP(p,id) { m_class=prs1_class_name; - properties["Brand"]="Philips Respironics"; - properties["Model"]="System One"; + properties[STR_PROP_Brand]="Philips Respironics"; + properties[STR_PROP_Model]="System One"; } PRS1::~PRS1() @@ -137,7 +137,7 @@ Machine *PRS1Loader::CreateMachine(QString serial,Profile *profile) bool found=false; QList::iterator i; for (i=ml.begin(); i!=ml.end(); i++) { - if (((*i)->GetClass()=="PRS1") && ((*i)->properties["Serial"]==serial)) { + if (((*i)->GetClass()==STR_MACH_PRS1) && ((*i)->properties[STR_PROP_Serial]==serial)) { PRS1List[serial]=*i; //static_cast(*i); found=true; break; @@ -151,7 +151,7 @@ Machine *PRS1Loader::CreateMachine(QString serial,Profile *profile) PRS1List[serial]=m; profile->AddMachine(m); - m->properties["Serial"]=serial; + m->properties[STR_PROP_Serial]=serial; return m; } bool isdigit(QChar c) @@ -250,10 +250,10 @@ bool PRS1Loader::ParseProperties(Machine *m,QString filename) int i=pt.toInt(&ok,16); if (ok) { if (ModelMap.find(i)!=ModelMap.end()) { - m->properties["SubModel"]=ModelMap[i]; + m->properties[STR_PROP_SubModel]=ModelMap[i]; } } - if (prop["SerialNumber"]!=m->properties["Serial"]) { + if (prop["SerialNumber"]!=m->properties[STR_PROP_Serial]) { qDebug() << "Serial Number in PRS1 properties.txt doesn't match directory structure"; } else prop.erase(prop.find("SerialNumber")); // already got it stored. @@ -421,7 +421,7 @@ int PRS1Loader::OpenMachine(Machine *m,QString path,Profile *profile) } - m->properties["DataVersion"]=QString().sprintf("%i",prs1_data_version); + m->properties[STR_PROP_DataVersion]=QString().sprintf("%i",prs1_data_version); m->properties["LastImported"]=QDateTime::currentDateTime().toString(Qt::ISODate); m->Save(); // Save any new sessions to disk in our format if (qprogress) qprogress->setValue(100); diff --git a/SleepLib/loader_plugins/prs1_loader.h b/SleepLib/loader_plugins/prs1_loader.h index f702bee6..b132bf7c 100644 --- a/SleepLib/loader_plugins/prs1_loader.h +++ b/SleepLib/loader_plugins/prs1_loader.h @@ -39,7 +39,7 @@ public: const int max_load_buffer_size=1024*1024; -const QString prs1_class_name="PRS1"; +const QString prs1_class_name=STR_MACH_PRS1; /*! \class PRS1Loader \brief Philips Respironics System One Loader Module diff --git a/SleepLib/loader_plugins/resmed_loader.cpp b/SleepLib/loader_plugins/resmed_loader.cpp index b2bdd4a4..d2cf1cb0 100644 --- a/SleepLib/loader_plugins/resmed_loader.cpp +++ b/SleepLib/loader_plugins/resmed_loader.cpp @@ -222,7 +222,7 @@ Machine *ResmedLoader::CreateMachine(QString serial,Profile *profile) bool found=false; QList::iterator i; for (i=ml.begin(); i!=ml.end(); i++) { - if (((*i)->GetClass()==resmed_class_name) && ((*i)->properties["Serial"]==serial)) { + if (((*i)->GetClass()==resmed_class_name) && ((*i)->properties[STR_PROP_Serial]==serial)) { ResmedList[serial]=*i; //static_cast(*i); found=true; break; @@ -237,11 +237,11 @@ Machine *ResmedLoader::CreateMachine(QString serial,Profile *profile) ResmedList[serial]=m; profile->AddMachine(m); - m->properties["Serial"]=serial; - m->properties["Brand"]="ResMed"; + m->properties[STR_PROP_Serial]=serial; + m->properties[STR_PROP_Brand]=STR_MACH_ResMed; QString a; a.sprintf("%i",resmed_data_version); - m->properties["DataVersion"]=a; + m->properties[STR_PROP_DataVersion]=a; return m; @@ -375,12 +375,12 @@ int ResmedLoader::Open(QString & path,Profile *profile) qDebug() << "edf Serial number doesn't match STR.edf!"; } } else if (i.key()=="PNA") { - //m->properties["Model"]=""; //i.value(); + //m->properties[STR_PROP_Model]=""; //i.value(); } else if (i.key()=="PCD") { bool ok; int j=i.value().toInt(&ok); if (RMS9ModelMap.find(j)!=RMS9ModelMap.end()) { - m->properties["Model"]=RMS9ModelMap[j]; + m->properties[STR_PROP_Model]=RMS9ModelMap[j]; } } else { m->properties[i.key()]=i.value(); @@ -424,19 +424,19 @@ int ResmedLoader::Open(QString & path,Profile *profile) } else mode=0; // AutoSV machines don't have both fields - sig=stredf.lookupSignal("EPR"); + sig=stredf.lookupSignal(RMS9_EPR); if (sig) { sess->settings[RMS9_EPR]=sig->data[dn]; } - sig=stredf.lookupSignal("EPRLevel"); + sig=stredf.lookupSignal(RMS9_EPRSet); if (sig) { sess->settings[RMS9_EPRSet]=sig->data[dn]; } if (mode==0) { sess->settings[CPAP_Mode]=MODE_CPAP; - sig=stredf.lookupSignal("Set Pressure"); + sig=stredf.lookupSignal("Set Pressure"); // ?? What's meant by Set Pressure? if (sig) { EventDataType pressure=sig->data[dn]*sig->gain; sess->settings[CPAP_PressureMin]=pressure; @@ -453,13 +453,13 @@ int ResmedLoader::Open(QString & path,Profile *profile) sess->settings[CPAP_Mode]=MODE_APAP; } - sig=stredf.lookupSignal("Min Pressure"); + sig=stredf.lookupSignal(CPAP_PressureMin); if (sig) { EventDataType pressure=sig->data[dn]*sig->gain; sess->settings[CPAP_PressureMin]=pressure; sess->setMin(CPAP_Pressure,pressure); } - sig=stredf.lookupSignal("Max Pressure"); + sig=stredf.lookupSignal(CPAP_PressureMax); if (sig) { EventDataType pressure=sig->data[dn]*sig->gain; sess->settings[CPAP_PressureMax]=pressure; @@ -882,10 +882,10 @@ void ResInitModelMap() resmed_codes["Set Pressure"].push_back("Eingest. Druck"); resmed_codes["Set Pressure"].push_back("Set Pressure"); // Prescription resmed_codes["Set Pressure"].push_back("Pres. prescrite"); - resmed_codes["EPR"].push_back("EPR"); - resmed_codes["EPRLevel"].push_back("EPR Level"); - resmed_codes["EPRLevel"].push_back("EPR-Stufe"); - resmed_codes["EPRLevel"].push_back("Niveau EPR"); + resmed_codes[RMS9_EPR].push_back("EPR"); + resmed_codes[RMS9_EPRSet].push_back("EPR Level"); + resmed_codes[RMS9_EPRSet].push_back("EPR-Stufe"); + resmed_codes[RMS9_EPRSet].push_back("Niveau EPR"); resmed_codes[CPAP_PressureMax].push_back("Max Pressure"); resmed_codes[CPAP_PressureMax].push_back("Max. Druck"); resmed_codes[CPAP_PressureMax].push_back("Pression max."); diff --git a/SleepLib/loader_plugins/resmed_loader.h b/SleepLib/loader_plugins/resmed_loader.h index 79b59815..54eb591f 100644 --- a/SleepLib/loader_plugins/resmed_loader.h +++ b/SleepLib/loader_plugins/resmed_loader.h @@ -24,7 +24,7 @@ const int resmed_data_version=5; // //******************************************************************************************** -const QString resmed_class_name="ResMed"; +const QString resmed_class_name=STR_MACH_ResMed; /*! \struct EDFHeader \brief Represents the EDF+ header structure, used as a place holder while processing the text data. diff --git a/SleepLib/loader_plugins/zeo_loader.cpp b/SleepLib/loader_plugins/zeo_loader.cpp index 20d95424..b05c7ac0 100644 --- a/SleepLib/loader_plugins/zeo_loader.cpp +++ b/SleepLib/loader_plugins/zeo_loader.cpp @@ -73,11 +73,11 @@ Machine *ZEOLoader::CreateMachine(Profile *profile) Machine *m=new SleepStage(profile,0); m->SetClass(zeo_class_name); - m->properties["Brand"]="ZEO"; - m->properties["Model"]="Personal Sleep Coach"; + m->properties[STR_PROP_Brand]="ZEO"; + m->properties[STR_PROP_Model]="Personal Sleep Coach"; QString s; s.sprintf("%i",zeo_data_version); - m->properties["DataVersion"]=s; + m->properties[STR_PROP_DataVersion]=s; profile->AddMachine(m); diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index f203d309..d1c9ef22 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -171,7 +171,7 @@ bool Machine::Purge(int secret) // It would be joyous if this function screwed up.. - QString path=profile->Get("DataFolder")+"/"+hexid(); + QString path=profile->Get(STR_GEN_DataFolder)+"/"+hexid(); QDir dir(path); @@ -216,7 +216,7 @@ const quint32 channel_version=1; bool Machine::Load() { - QString path=profile->Get("DataFolder")+"/"+hexid(); + QString path=profile->Get(STR_GEN_DataFolder)+"/"+hexid(); QDir dir(path); qDebug() << "Loading " << path; @@ -272,7 +272,7 @@ bool Machine::Load() } bool Machine::SaveSession(Session *sess) { - QString path=profile->Get("DataFolder")+"/"+hexid(); + QString path=profile->Get(STR_GEN_DataFolder)+"/"+hexid(); if (sess->IsChanged()) sess->Store(path); return true; } @@ -282,7 +282,7 @@ bool Machine::Save() //int size; int cnt=0; - QString path=profile->Get("DataFolder")+"/"+hexid(); + QString path=profile->Get(STR_GEN_DataFolder)+"/"+hexid(); QDir dir(path); if (!dir.exists()) { dir.mkdir(path); diff --git a/SleepLib/preferences.h b/SleepLib/preferences.h index 0d853902..007e2a8d 100644 --- a/SleepLib/preferences.h +++ b/SleepLib/preferences.h @@ -58,7 +58,7 @@ public: } //! \brief Returns true if preference 'name' exists - bool Exists(QString name) { + bool contains(QString name) { return (p_preferences.contains(name)); } diff --git a/SleepLib/profiles.cpp b/SleepLib/profiles.cpp index 70f2878b..3eeee5d7 100644 --- a/SleepLib/profiles.cpp +++ b/SleepLib/profiles.cpp @@ -29,7 +29,7 @@ Profile * p_profile; Profile::Profile() :Preferences(),is_first_day(true) { - p_name="Profile"; + p_name=STR_GEN_Profile; p_path=PREF.Get("{home}/Profiles"); machlist.clear(); @@ -45,10 +45,10 @@ Profile::Profile(QString path) :Preferences(),is_first_day(true) { const QString xmlext=".xml"; - p_name="Profile"; + p_name=STR_GEN_Profile; if (path.isEmpty()) p_path=GetAppRoot(); else p_path=path; - (*this)["DataFolder"]=p_path; + (*this)[STR_GEN_DataFolder]=p_path; if (!p_path.endsWith("/")) p_path+="/"; p_filename=p_path+p_name+xmlext; machlist.clear(); @@ -123,7 +123,7 @@ Profile::~Profile() void Profile::DataFormatError(Machine *m) { QString msg=QObject::tr("Software changes have been made that require the reimporting of the following machines data:\n\n"); - msg=msg+m->properties["Brand"]+" "+m->properties["Model"]+" "+m->properties["Serial"]; + msg=msg+m->properties[STR_PROP_Brand]+" "+m->properties[STR_PROP_Model]+" "+m->properties[STR_PROP_Serial]; msg=msg+QObject::tr("\n\nThis is still only alpha software and these changes are sometimes necessary.\n\n"); msg=msg+QObject::tr("I can automatically purge this data for you, or you can cancel now and continue to run in a previous version.\n\n"); msg=msg+QObject::tr("Would you like me to purge this data this for you so you can run the new version?"); @@ -132,7 +132,7 @@ void Profile::DataFormatError(Machine *m) if (!m->Purge(3478216)) { // Do not copy this line without thinking.. You will be eaten by a Grue if you do - QMessageBox::critical(NULL,QObject::tr("Purge Failed"),QObject::tr("Sorry, I could not purge this data, which means this version of SleepyHead can't start.. SleepyHead's Data folder needs to be removed manually\n\nThis folder currently resides at the following location:\n")+PREF["DataFolder"].toString(),QMessageBox::Ok); + QMessageBox::critical(NULL,QObject::tr("Purge Failed"),QObject::tr("Sorry, I could not purge this data, which means this version of SleepyHead can't start.. SleepyHead's Data folder needs to be removed manually\n\nThis folder currently resides at the following location:\n")+PREF[STR_GEN_DataFolder].toString(),QMessageBox::Ok); exit(-1); } } else { @@ -175,17 +175,17 @@ void Profile::LoadMachineData() if (loader) { long v=loader->Version(); long cv=0; - if (m->properties.find("DataVersion")==m->properties.end()) { - m->properties["DataVersion"]="0"; + if (m->properties.find(STR_PROP_DataVersion)==m->properties.end()) { + m->properties[STR_PROP_DataVersion]="0"; } bool ok; - cv=m->properties["DataVersion"].toLong(&ok); + cv=m->properties[STR_PROP_DataVersion].toLong(&ok); if (!ok || cvproperties["DataVersion"]=s; // Dont need to nag again if they are too lazy. + m->properties[STR_PROP_DataVersion]=s; // Dont need to nag again if they are too lazy. } else { try { m->Load(); @@ -466,14 +466,14 @@ Profile *Create(QString name) Profile *prof=new Profile(path); prof->Open(); profiles[name]=prof; - prof->Set("Username",name); + prof->user->setUserName(name); //prof->Set("Realname",realname); - //if (!password.isEmpty()) prof->Set("Password",SHA1(password)); - prof->Set("DataFolder","{home}/Profiles/{Username}"); + //if (!password.isEmpty()) prof.user->setPassword(password); + prof->Set(STR_GEN_DataFolder,"{home}/Profiles/{Username}"); Machine *m=new Machine(prof,0); m->SetClass("Journal"); - m->properties["Brand"]="Virtual"; + m->properties[STR_PROP_Brand]="Virtual"; m->SetType(MT_JOURNAL); prof->AddMachine(m); diff --git a/SleepLib/profiles.h b/SleepLib/profiles.h index 2dc1c575..40399813 100644 --- a/SleepLib/profiles.h +++ b/SleepLib/profiles.h @@ -242,6 +242,9 @@ public: void setLanguage(QString language) { (*m_profile)[UI_STR_Language]=language; } void setDaylightSaving(bool ds) { (*m_profile)[UI_STR_DST]=ds; } + bool hasPassword() { + return !((*m_profile)[UI_STR_Password].toString().isEmpty()); + } bool checkPassword(QString password) { QByteArray ba=password.toUtf8(); return ((*m_profile)[UI_STR_Password].toString()==QString(QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex())); diff --git a/UpdaterWindow.cpp b/UpdaterWindow.cpp index 1d78a61d..840e5bb7 100644 --- a/UpdaterWindow.cpp +++ b/UpdaterWindow.cpp @@ -123,7 +123,7 @@ void UpdaterWindow::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) ui->tableWidget->item(current_row,2)->setText(QString::number(bytesTotal/1048576.0,'f',3)+"MB"); } //ui->progressBar->setValue(f); - int elapsed=dltime.elapsed(); + // int elapsed=dltime.elapsed(); } void UpdaterWindow::requestFile() @@ -473,7 +473,7 @@ void UpdaterWindow::upgradeNext() ui->downloadTitle->setText(tr("Update Complete!")); ui->FinishedButton->setVisible(true); ui->downloadLabel->setText(tr("Updates Complete. SleepyHead needs to restart now, click Finished to do so.")); - PREF["Updates_LastChecked"]=QDateTime::currentDateTime(); + PREF[STR_GEN_UpdatesLastChecked]=QDateTime::currentDateTime(); } else { ui->downloadTitle->setText(tr("Update Failed :(")); success=false; diff --git a/daily.cpp b/daily.cpp index 022ef963..370a2a77 100644 --- a/daily.cpp +++ b/daily.cpp @@ -89,7 +89,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) layout->addWidget(scrollbar,0); int default_height=PROFILE.appearance->graphHeight(); - SF=new gGraph(GraphView,tr("Event Flags"),tr("Event Flags"),default_height); + SF=new gGraph(GraphView,STR_TR_EventFlags,STR_TR_EventFlags,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); @@ -114,7 +114,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared) // Event Pie Chart (for snapshot purposes) // TODO: Convert snapGV to generic for snapshotting multiple graphs (like reports does) -// TAP=new gGraph(GraphView,"Time@Pressure","cmH2O",100); +// TAP=new gGraph(GraphView,"Time@Pressure",STR_UNIT_CMH2O,100); // TAP->showTitle(false); // gTAPGraph * tap=new gTAPGraph(CPAP_Pressure,GST_Line); // TAP->AddLayer(AddCPAP(tap)); @@ -679,26 +679,26 @@ void Daily::Load(QDate date) QString submodel; //=tr("Unknown Model"); //html+=""+tr("Machine Information")+"\n"; - if (cpap->machine->properties.find("SubModel")!=cpap->machine->properties.end()) - submodel="
"+cpap->machine->properties["SubModel"]; - html+=""+cpap->machine->properties["Brand"]+"
"+cpap->machine->properties["Model"]+" "+cpap->machine->properties["ModelNumber"]+submodel+"\n"; + if (cpap->machine->properties.find(STR_PROP_SubModel)!=cpap->machine->properties.end()) + submodel="
"+cpap->machine->properties[STR_PROP_SubModel]; + html+=""+cpap->machine->properties[STR_PROP_Brand]+"
"+cpap->machine->properties[STR_PROP_Model]+" "+cpap->machine->properties[STR_PROP_ModelNumber]+submodel+"\n"; if (PROFILE.session->showSerialNumbers()) { - html+=""+cpap->machine->properties["Serial"]+"\n"; + html+=""+cpap->machine->properties[STR_PROP_Serial]+"\n"; } CPAPMode mode=(CPAPMode)(int)cpap->settings_max(CPAP_Mode); html+="Mode: "; EventDataType min=cpap->settings_min(CPAP_PressureMin); EventDataType max=cpap->settings_max(CPAP_PressureMax); - if (mode==MODE_CPAP) html+=tr("CPAP")+" "+QString::number(min)+tr("cmH2O"); - else if (mode==MODE_APAP) html+=tr("APAP")+" "+QString::number(min)+"-"+QString::number(max)+tr("cmH2O"); + if (mode==MODE_CPAP) html+=tr("CPAP")+" "+QString::number(min)+STR_UNIT_CMH2O; + else if (mode==MODE_APAP) html+=tr("APAP")+" "+QString::number(min)+"-"+QString::number(max)+STR_UNIT_CMH2O; else if (mode==MODE_BIPAP) html+=tr("Bi-Level"); else if (mode==MODE_ASV) html+=tr("ASV"); else html+=tr("Unknown"); html+="\n"; - html+=""+tr("Date")+""+tr("Sleep")+""+tr("Wake")+""+tr("Hours")+""; + html+=""+tr("Date")+""+tr("Sleep")+""+tr("Wake")+""+STR_UNIT_Hours+""; int tt=qint64(cpap->total_time())/1000L; QDateTime date=QDateTime::fromTime_t(cpap->first()/1000L); QDateTime date2=QDateTime::fromTime_t(cpap->last()/1000L); @@ -715,27 +715,27 @@ void Daily::Load(QDate date) QString cs; if (!isBrick) { - if (cpap->machine->GetClass()=="ResMed") { + if (cpap->machine->GetClass()==STR_MACH_ResMed) { cs="4 width='100%' align=center>"; } else cs="2 width='50%'>"; html+="" ""+tr("AHI")+""+QString().sprintf("%.2f",ahi)+"\n" " "+tr("Hypopnea")+""+QString().sprintf("%.2f",hi)+"\n"; - if (cpap->machine->GetClass()=="ResMed") { + if (cpap->machine->GetClass()==STR_MACH_ResMed) { html+=" "+tr("Unspecified Apnea")+""+QString().sprintf("%.2f",uai)+"\n"; } html+=" "+tr("Obstructive")+""+QString().sprintf("%.2f",oai)+"\n" " "+tr("Clear Airway")+""+QString().sprintf("%.2f",cai)+"\n" ""; - if (cpap->machine->GetClass()=="PRS1") { + if (cpap->machine->GetClass()==STR_MACH_PRS1) { html+="" "\n" "\n" "\n" "\n" "
 "+tr("RERA")+""+QString().sprintf("%.2f",rei)+"
 "+tr("Flow Limit")+""+a.sprintf("%.2f",fli)+"
 "+tr("Vsnore")+""+QString().sprintf("%.2f",vsi)+"
 "+tr("PB/CSR")+""+QString().sprintf("%.2f",csr)+"%
"; - } else if (cpap->machine->GetClass()=="Intellipap") { + } else if (cpap->machine->GetClass()==STR_MACH_Intellipap) { html+="" "\n" "\n" @@ -858,7 +858,7 @@ void Daily::Load(QDate date) html+="\n"; } */ html+="
 "+tr("NRI")+""+QString().sprintf("%.2f",nri)+"
 "+tr("Leak Idx")+""+a.sprintf("%.2f",lki)+"
"; - if (cpap->machine->GetClass()=="PRS1") { + if (cpap->machine->GetClass()==STR_MACH_PRS1) { int i=cpap->settings_max(PRS1_FlexMode); int j=cpap->settings_max(PRS1_FlexSet); QString flexstr=(i>1) ? schema::channel[PRS1_FlexMode].option(i)+" "+schema::channel[PRS1_FlexSet].option(j) : "None"; @@ -866,11 +866,11 @@ void Daily::Load(QDate date) html+=""; i=cpap->settings_max(PRS1_HumidSetting); - QString humid=(i==0) ? tr("Off") : "x"+QString::number(i); + QString humid=(i==0) ? STR_GEN_Off : "x"+QString::number(i); html+=""; - } else if (cpap->machine->GetClass()=="ResMed") { - int epr=cpap->settings_max("EPR"); - int epr2=cpap->settings_max("EPRSet"); + } else if (cpap->machine->GetClass()==STR_MACH_ResMed) { + int epr=cpap->settings_max(RMS9_EPR); + int epr2=cpap->settings_max(RMS9_EPRSet); html+=""; //epr=schema::channel[PRS1_FlexSet].optionString(pr)+QString(" x%1").arg((int)cpap->settings_max(PRS1_FlexSet)); @@ -1174,7 +1174,7 @@ Session * Daily::CreateJournalSession(QDate date) if (!m) { m=new Machine(p_profile,0); m->SetClass("Journal"); - m->properties["Brand"]="Virtual"; + m->properties[STR_PROP_Brand]="Virtual"; m->SetType(MT_JOURNAL); PROFILE.AddMachine(m); } @@ -1239,7 +1239,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(tr("Event Flags")); + gGraph *g=GraphView->findGraph(STR_TR_EventFlags); if (!g) return; if (strmin_x) { st=g->rmin_x; @@ -1331,7 +1331,7 @@ void Daily::on_evViewSlider_valueChanged(int value) int winsize=value*60; - gGraph *g=GraphView->findGraph("Event Flags"); + gGraph *g=GraphView->findGraph(STR_TR_EventFlags); if (!g) return; qint64 st=g->min_x; qint64 et=g->max_x; @@ -1463,7 +1463,7 @@ void Daily::on_weightSpinBox_valueChanged(double arg1) gGraphView *gv=mainwin->getOverview()->graphView(); gGraph *g; if (gv) { - g=gv->findGraph(tr("Weight")); + g=gv->findGraph(STR_TR_Weight); if (g) g->setDay(NULL); } if ((height>0) && (kg>0)) { @@ -1472,7 +1472,7 @@ void Daily::on_weightSpinBox_valueChanged(double arg1) ui->BMI->setVisible(true); journal->settings[Journal_BMI]=bmi; if (gv) { - g=gv->findGraph(tr("BMI")); + g=gv->findGraph(STR_TR_BMI); if (g) g->setDay(NULL); } } @@ -1491,7 +1491,7 @@ void Daily::on_ouncesSpinBox_valueChanged(int arg1) gGraph *g; if (mainwin->getOverview()) { - g=mainwin->getOverview()->graphView()->findGraph(tr("Weight")); + g=mainwin->getOverview()->graphView()->findGraph(STR_TR_Weight); if (g) g->setDay(NULL); } @@ -1502,7 +1502,7 @@ void Daily::on_ouncesSpinBox_valueChanged(int arg1) journal->settings[Journal_BMI]=bmi; if (mainwin->getOverview()) { - g=mainwin->getOverview()->graphView()->findGraph(tr("BMI")); + g=mainwin->getOverview()->graphView()->findGraph(STR_TR_BMI); if (g) g->setDay(NULL); } } diff --git a/main.cpp b/main.cpp index ff15c2b6..36dde879 100644 --- a/main.cpp +++ b/main.cpp @@ -117,24 +117,24 @@ int main(int argc, char *argv[]) if (force_login_screen) skip_login=false; QDateTime lastchecked, today=QDateTime::currentDateTime(); - if (!PREF.Exists("Updates_AutoCheck")) { - PREF["Updates_AutoCheck"]=true; - PREF["Updates_CheckFrequency"]=7; + if (!PREF.contains(STR_GEN_UpdatesAutoCheck)) { + PREF[STR_GEN_UpdatesAutoCheck]=true; + PREF[STR_GEN_UpdateCheckFrequency]=7; } bool check_updates=false; - if (PREF["Updates_AutoCheck"].toBool()) { - int update_frequency=PREF["Updates_CheckFrequency"].toInt(); + if (PREF[STR_GEN_UpdatesAutoCheck].toBool()) { + int update_frequency=PREF[STR_GEN_UpdateCheckFrequency].toInt(); int days=1000; // p_pref ->Get - lastchecked=PREF["Updates_LastChecked"].toDateTime(); - if (PREF.Exists("Updates_LastChecked")) { + lastchecked=PREF[STR_GEN_UpdatesLastChecked].toDateTime(); + if (PREF.contains(STR_GEN_UpdatesLastChecked)) { days=lastchecked.secsTo(today); days/=86400; }; if (days>update_frequency) { //QMessageBox::information(NULL,"Check for updates","Placeholder. Would automatically check for updates here.",QMessageBox::Ok); check_updates=true; - //PREF["Updates_LastChecked"]=today; + //PREF[STR_GEN_UpdatesLastChecked]=today; } } @@ -146,7 +146,7 @@ int main(int argc, char *argv[]) // Show New User wizard.. } else { - if (PREF.Exists("VersionString")) { + if (PREF.contains("VersionString")) { QString V=PREF["VersionString"].toString(); if (VersionString()>V) { release_notes(); @@ -160,7 +160,7 @@ int main(int argc, char *argv[]) if (profsel.result()==ProfileSelect::Rejected) { exit(1); } - p_profile=Profiles::Get(PREF["Profile"].toString()); + p_profile=Profiles::Get(PREF[STR_GEN_Profile].toString()); } else p_profile=NULL; if (!p_profile) { if (profsel.exec()==ProfileSelect::Rejected) { @@ -170,9 +170,9 @@ int main(int argc, char *argv[]) } PREF["VersionString"]=VersionString(); - p_profile=Profiles::Get(PREF["Profile"].toString()); + p_profile=Profiles::Get(PREF[STR_GEN_Profile].toString()); - //if (!PREF.Exists("Profile")) PREF["Profile"]=getUserName(); + //if (!PREF.Exists(STR_GEN_Profile)) PREF[STR_GEN_Profile]=getUserName(); //int id=QFontDatabase::addApplicationFont(":/fonts/FreeSans.ttf"); /* QFontDatabase fdb; @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) qDebug() << "Loaded Font: " << (*i); } */ - if (!PREF.Exists("Fonts_Application_Name")) { + if (!PREF.contains("Fonts_Application_Name")) { PREF["Fonts_Application_Name"]="Sans Serif"; PREF["Fonts_Application_Size"]=10; PREF["Fonts_Application_Bold"]=false; diff --git a/mainwindow.cpp b/mainwindow.cpp index e541c751..8dc321d9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -74,7 +74,7 @@ MainWindow::MainWindow(QWidget *parent) : QString version=VersionString(); if (QString(GIT_BRANCH)!="master") version+=QString(" ")+QString(GIT_BRANCH); - this->setWindowTitle(tr("SleepyHead")+QString(" v%1 (Profile: %2)").arg(version).arg(PREF["Profile"].toString())); + this->setWindowTitle(tr("SleepyHead")+QString(" v%1 (Profile: %2)").arg(version).arg(PREF[STR_GEN_Profile].toString())); ui->tabWidget->setCurrentIndex(0); overview=NULL; @@ -195,13 +195,13 @@ void MainWindow::Startup() SnapshotGraph->hide(); daily=new Daily(ui->tabWidget,NULL); - ui->tabWidget->insertTab(1,daily,tr("Daily")); + ui->tabWidget->insertTab(1,daily,STR_TR_Daily); overview=new Overview(ui->tabWidget,daily->graphView()); - ui->tabWidget->insertTab(2,overview,tr("Overview")); + ui->tabWidget->insertTab(2,overview,STR_TR_Overview); if (PROFILE.oxi->oximetryEnabled()) { oximetry=new Oximetry(ui->tabWidget,daily->graphView()); - ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); + ui->tabWidget->insertTab(3,oximetry,STR_TR_Oximetry); } @@ -374,7 +374,7 @@ void MainWindow::on_dailyButton_clicked() { ui->tabWidget->setCurrentWidget(daily); daily->RedrawGraphs(); - qstatus2->setText("Daily"); + qstatus2->setText(STR_TR_Daily); } void MainWindow::JumpDaily() { @@ -384,7 +384,7 @@ void MainWindow::JumpDaily() void MainWindow::on_overviewButton_clicked() { ui->tabWidget->setCurrentWidget(overview); - qstatus2->setText("Overview"); + qstatus2->setText(STR_TR_Overview); } void MainWindow::on_webView_loadFinished(bool arg1) @@ -435,7 +435,7 @@ void MainWindow::on_action_About_triggered() void MainWindow::on_actionDebug_toggled(bool checked) { - PROFILE["ShowDebug"]=checked; + PROFILE.general->setShowDebug(checked); if (checked) { ui->logText->show(); } else { @@ -476,17 +476,17 @@ void MainWindow::on_oximetryButton_clicked() { bool first=false; if (!oximetry) { - if (!PROFILE.Exists("EnableOximetry") || !PROFILE["EnableOximetry"].toBool()) { + if (!PROFILE.oxi->oximetryEnabled()) { if (QMessageBox::question(this,"Question","Do you have a CMS50[x] Oximeter?\nOne is required to use this section.",QMessageBox::Yes,QMessageBox::No)==QMessageBox::No) return; - PROFILE["EnableOximetry"]=true; + PROFILE.oxi->setOximetryEnabled(true); } oximetry=new Oximetry(ui->tabWidget,daily->graphView()); - ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); + ui->tabWidget->insertTab(3,oximetry,STR_TR_Oximetry); first=true; } ui->tabWidget->setCurrentWidget(oximetry); if (!first) oximetry->RedrawGraphs(); - qstatus2->setText("Oximetry"); + qstatus2->setText(STR_TR_Oximetry); } void MainWindow::CheckForUpdates() @@ -542,12 +542,12 @@ void MainWindow::updatestatusBarMessage (const QString & text) void MainWindow::on_actionPrint_Report_triggered() { if (ui->tabWidget->currentWidget()==overview) { - PrintReport(overview->graphView(),tr("Overview")); + PrintReport(overview->graphView(),STR_TR_Overview); } else if (ui->tabWidget->currentWidget()==daily) { - PrintReport(daily->graphView(),tr("Daily"),daily->getDate()); + PrintReport(daily->graphView(),STR_TR_Daily,daily->getDate()); } else if (ui->tabWidget->currentWidget()==oximetry) { if (oximetry) - PrintReport(oximetry->graphView(),tr("Oximetry")); + PrintReport(oximetry->graphView(),STR_TR_Oximetry); } else { //QPrinter printer(); //ui->webView->print(printer) @@ -558,7 +558,7 @@ void MainWindow::on_actionPrint_Report_triggered() void MainWindow::on_action_Edit_Profile_triggered() { NewProfile newprof(this); - newprof.edit(PREF["Profile"].toString()); + newprof.edit(PREF[STR_GEN_Profile].toString()); newprof.exec(); } @@ -603,7 +603,7 @@ EventList *packEventList(EventList *ev) EventList *nev=new EventList(EVL_Event); EventDataType val,lastval=0; - qint64 time,lasttime=0,lasttime2=0; + qint64 time,lasttime=0;//,lasttime2=0; lastval=ev->data(0); lasttime=ev->time(0); @@ -614,7 +614,7 @@ EventList *packEventList(EventList *ev) time=ev->time(i); if (val!=lastval) { nev->AddEvent(time,val); - lasttime2=time; + //lasttime2=time; } lastval=val; lasttime=time; @@ -640,7 +640,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) QString username=PROFILE.Get("_{Username}_"); bool print_bookmarks=false; - if (name=="Daily") { + if (name==STR_TR_Daily) { QVariantList book_start; journal=getDaily()->GetJournalSession(getDaily()->getDate()); if (journal && journal->settings.contains(Bookmark_Start)) { @@ -655,28 +655,28 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) QPrinter * printer; - bool highres; - bool aa_setting=PROFILE.ExistsAndTrue("UseAntiAliasing"); + //bool highres; + bool aa_setting=PROFILE.appearance->antiAliasing(); #ifdef Q_WS_MAC - PROFILE["HighResPrinting"]=true; // forced on + PROFILE.appearance->setHighResPrinting(true); // forced on // bool force_antialiasing=true; //#else #endif - bool force_antialiasing=PROFILE.ExistsAndTrue("UseAntiAliasing"); + bool force_antialiasing=aa_setting; - if (PROFILE.ExistsAndTrue("HighResPrinting")) { + if (PROFILE.appearance->highResPrinting()) { printer=new QPrinter(QPrinter::HighResolution); - highres=true; + //highres=true; } else { printer=new QPrinter(QPrinter::ScreenResolution); - highres=false; + //highres=false; } #ifdef Q_WS_X11 printer->setPrinterName("Print to File (PDF)"); printer->setOutputFormat(QPrinter::PdfFormat); - QString filename=PREF.Get("{home}/"+name+username+date.toString(Qt::ISODate)+".pdf");//QFileDialog::getSaveFileName(this,"Select filename to save PDF report to",,"PDF Files (*.pdf)"); + QString filename=PREF.Get("{home}/"+name+username+date.toString(Qt::ISODate)+".pdf"); printer->setOutputFileName(filename); #endif @@ -740,12 +740,12 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) painter.setFont(report_font); int maxy=0; - if (!PROFILE["FirstName"].toString().isEmpty()) { - QString userinfo=tr("Name:\t %1, %2\n").arg(PROFILE["LastName"].toString()).arg(PROFILE["FirstName"].toString()); - userinfo+=tr("DOB:\t%1\n").arg(PROFILE["DOB"].toString()); - userinfo+=tr("Phone:\t%1\n").arg(PROFILE["Phone"].toString()); - userinfo+=tr("Email:\t%1\n").arg(PROFILE["EmailAddress"].toString()); - if (!PROFILE["Address"].toString().isEmpty()) userinfo+=tr("\nAddress:\n%1").arg(PROFILE["Address"].toString()); + if (!PROFILE.user->firstName().isEmpty()) { + QString userinfo=tr("Name:\t %1, %2\n").arg(PROFILE.user->lastName()).arg(PROFILE.user->firstName()); + userinfo+=tr("DOB:\t%1\n").arg(PROFILE.user->DOB().toString(Qt::SystemLocaleShortDate)); + userinfo+=tr("Phone:\t%1\n").arg(PROFILE.user->phone()); + userinfo+=tr("Email:\t%1\n").arg(PROFILE.user->email()); + if (!PROFILE.user->address().isEmpty()) userinfo+=tr("\nAddress:\n%1").arg(PROFILE.user->address()); QRectF bounds=painter.boundingRect(QRectF(0,top,virt_width,0),userinfo,QTextOption(Qt::AlignLeft | Qt::AlignTop)); painter.drawText(bounds,userinfo,QTextOption(Qt::AlignLeft | Qt::AlignTop)); @@ -753,7 +753,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) } int graph_slots=0; - if (name==tr("Daily")) { + if (name==STR_TR_Daily) { Day *cpap=PROFILE.GetDay(date,MT_CPAP); QString cpapinfo=date.toString(Qt::SystemLocaleLongDate)+"\n\n"; if (cpap) { @@ -769,9 +769,9 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) cpapinfo+=tr("Wake-up: ")+QDateTime::fromTime_t(l).time().toString("HH:mm:ss")+"\n\n"; QString submodel; cpapinfo+=tr("Machine: "); - if (cpap->machine->properties.find("SubModel")!=cpap->machine->properties.end()) - submodel="\n"+cpap->machine->properties["SubModel"]; - cpapinfo+=cpap->machine->properties["Brand"]+" "+cpap->machine->properties["Model"]+submodel; + if (cpap->machine->properties.find(STR_PROP_SubModel)!=cpap->machine->properties.end()) + submodel="\n"+cpap->machine->properties[STR_PROP_SubModel]; + cpapinfo+=cpap->machine->properties[STR_PROP_Brand]+" "+cpap->machine->properties[STR_PROP_Model]+submodel; CPAPMode mode=(CPAPMode)(int)cpap->settings_max(CPAP_Mode); cpapinfo+=tr("\nMode: "); @@ -823,13 +823,13 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) int ttop=bounds.height(); stats=tr("AI=%1 HI=%2 CAI=%3 ").arg(oai,0,'f',2).arg(hi,0,'f',2).arg(cai,0,'f',2); - if (cpap->machine->GetClass()=="PRS1") { + if (cpap->machine->GetClass()==STR_MACH_PRS1) { stats+=tr("REI=%1 VSI=%2 FLI=%3 PB/CSR=%4\%") .arg(rei,0,'f',2).arg(vsi,0,'f',2) .arg(fli,0,'f',2).arg(csr,0,'f',2); - } else if (cpap->machine->GetClass()=="ResMed") { + } else if (cpap->machine->GetClass()==STR_MACH_ResMed) { stats+=tr("UAI=%1 ").arg(uai,0,'f',2); - } else if (cpap->machine->GetClass()=="Intellipap") { + } else if (cpap->machine->GetClass()==STR_MACH_Intellipap) { stats+=tr("NRI=%1 LKI=%2 EPI=%3").arg(nri,0,'f',2).arg(lki,0,'f',2).arg(exp,0,'f',2); } bounds=painter.boundingRect(QRectF(0,top+ttop,virt_width,0),stats,QTextOption(Qt::AlignCenter)); @@ -844,7 +844,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) } graph_slots=2; - } else if (name==tr("Overview")) { + } else if (name==STR_TR_Overview) { QDateTime first=QDateTime::fromTime_t((*gv)[0]->min_x/1000L); QDateTime last=QDateTime::fromTime_t((*gv)[0]->max_x/1000L); QString ovinfo=tr("Reporting from %1 to %2").arg(first.date().toString(Qt::SystemLocaleShortDate)).arg(last.date().toString(Qt::SystemLocaleShortDate)); @@ -853,7 +853,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) if (bounds.height()>maxy) maxy=bounds.height(); graph_slots=1; - } else if (name==tr("Oximetry")) { + } else if (name==STR_TR_Oximetry) { QString ovinfo=tr("Reporting data goes here"); QRectF bounds=painter.boundingRect(QRectF(0,top,virt_width,0),ovinfo,QTextOption(Qt::AlignCenter)); painter.drawText(bounds,ovinfo,QTextOption(Qt::AlignCenter)); @@ -952,7 +952,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) top+=normal_height; } else top+=normal_height/2; - PROFILE["UseAntiAliasing"]=force_antialiasing; + PROFILE.appearance->setAntiAliasing(force_antialiasing); int tmb=g->m_marginbottom; g->m_marginbottom=0; @@ -961,7 +961,7 @@ void MainWindow::PrintReport(gGraphView *gv,QString name, QDate date) //g->showTitle(true); g->m_marginbottom=tmb; - PROFILE["UseAntiAliasing"]=aa_setting; + PROFILE.appearance->setAntiAliasing(aa_setting); painter.drawPixmap(0,top,virt_width,full_graph_height-normal_height,pm); top+=full_graph_height; @@ -992,9 +992,7 @@ void MainWindow::on_action_Rebuild_Oximetry_Index_triggered() QList machines=PROFILE.GetMachines(MT_OXIMETER); - bool ok; - int discard_threshold=PROFILE["OxiDiscardThreshold"].toInt(&ok); - if (!ok) discard_threshold=10; + int discard_threshold=PROFILE.oxi->oxiDiscardThreshold(); Machine *m; for (int z=0;zmachine; - QString path=PROFILE.Get("DataFolder")+QDir::separator()+m->hexid()+QDir::separator(); + QString path=PROFILE.Get(STR_GEN_DataFolder)+QDir::separator()+m->hexid()+QDir::separator(); QVector::iterator s; @@ -1152,7 +1150,7 @@ void MainWindow::on_actionAll_Data_for_current_CPAP_machine_triggered() qDebug() << "Gah!! no machine to purge"; return; } - if (QMessageBox::question(this,tr("Are you sure?"),tr("Are you sure you want to purge all CPAP data for the following machine:\n")+m->properties["Brand"]+" "+m->properties["Model"]+" "+m->properties["ModelNumber"]+" ("+m->properties["Serial"]+")",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { + if (QMessageBox::question(this,tr("Are you sure?"),tr("Are you sure you want to purge all CPAP data for the following machine:\n")+m->properties[STR_PROP_Brand]+" "+m->properties[STR_PROP_Model]+" "+m->properties[STR_PROP_ModelNumber]+" ("+m->properties[STR_PROP_Serial]+")",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { m->Purge(3478216); RestartApplication(); } diff --git a/newprofile.cpp b/newprofile.cpp index 7dfaa4ee..06875446 100644 --- a/newprofile.cpp +++ b/newprofile.cpp @@ -179,7 +179,7 @@ void NewProfile::on_nextButton_clicked() profile->user->setHeight(v); //profile->user->setUserName(ui->userNameEdit->text());?? - PREF["Profile"]=ui->userNameEdit->text(); + PREF[STR_GEN_Profile]=ui->userNameEdit->text(); this->accept(); @@ -243,7 +243,7 @@ void NewProfile::edit(const QString name) ui->userNameEdit->setReadOnly(true); ui->firstNameEdit->setText(profile->user->firstName()); ui->lastNameEdit->setText(profile->user->lastName()); - if (profile->Exists(UI_STR_Password)) { + if (profile->contains(UI_STR_Password)) { // leave the password box blank.. QString a="******"; ui->passwordEdit1->setText(a); diff --git a/overview.cpp b/overview.cpp index 6f707aa3..4975932a 100644 --- a/overview.cpp +++ b/overview.cpp @@ -108,8 +108,8 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : PULSE=createGraph(tr("Pulse Rate"),tr("Pulse Rate\n(bpm)")); SPO2=createGraph(tr("SpO2"),tr("Oxygen Saturation\n(%)")); - WEIGHT=createGraph(tr("Weight"),tr("Weight"),YT_Weight); - BMI=createGraph(tr("BMI"),tr("Body\nMass\nIndex")); + WEIGHT=createGraph(STR_TR_Weight,STR_TR_Weight,YT_Weight); + BMI=createGraph(STR_TR_BMI,tr("Body\nMass\nIndex")); ZOMBIE=createGraph(tr("Zombie"),tr("How you felt\n(0-10)")); ahihr=new SummaryChart(tr("AHI/Hr"),GT_LINE); @@ -117,12 +117,12 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : ahihr->addSlice(CPAP_AHI,QColor("orange"),ST_WAVG,false); AHIHR->AddLayer(ahihr); - weight=new SummaryChart(tr("Weight"),GT_LINE); + weight=new SummaryChart(STR_TR_Weight,GT_LINE); weight->setMachineType(MT_JOURNAL); weight->addSlice(Journal_Weight,QColor("black"),ST_SETAVG,true); WEIGHT->AddLayer(weight); - bmi=new SummaryChart(tr("BMI"),GT_LINE); + bmi=new SummaryChart(STR_TR_BMI,GT_LINE); bmi->setMachineType(MT_JOURNAL); bmi->addSlice(Journal_BMI,QColor("dark blue"),ST_SETAVG,true); BMI->AddLayer(bmi); @@ -146,11 +146,11 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : spo2->addSlice(OXI_SPO2,QColor("blue"),ST_MIN,true); SPO2->AddLayer(spo2); - uc=new SummaryChart(tr("Hours"),GT_BAR); + uc=new SummaryChart(STR_UNIT_Hours,GT_BAR); uc->addSlice("",QColor("green"),ST_HOURS,true); UC->AddLayer(uc); - us=new SummaryChart(tr("Hours"),GT_SESSIONS); + us=new SummaryChart(STR_UNIT_Hours,GT_SESSIONS); us->addSlice("",QColor("dark blue"),ST_HOURS,true); us->addSlice("",QColor("blue"),ST_SESSIONS,true); US->AddLayer(us); @@ -201,7 +201,7 @@ Overview::Overview(QWidget *parent,gGraphView * shared) : ptb->addSlice(CPAP_PTB,QColor("orange"),ST_WAVG,true); PTB->AddLayer(ptb); - pr=new SummaryChart(tr("cmH2O"),GT_LINE); + pr=new SummaryChart(STR_UNIT_CMH2O,GT_LINE); //PR->setRecMinY(4.0); //PR->setRecMaxY(12.0); pr->addSlice(CPAP_Pressure,QColor("dark green"),ST_WAVG,true); @@ -350,7 +350,7 @@ void Overview::on_toolButton_clicked() void Overview::on_printButton_clicked() { - mainwin->PrintReport(GraphView,tr("Overview")); // Must be translated the same as PrintReport checks. + mainwin->PrintReport(GraphView,STR_TR_Overview); // Must be translated the same as PrintReport checks. } void Overview::ResetGraphLayout() diff --git a/preferencesdialog.cpp b/preferencesdialog.cpp index e8c110c8..96440b78 100644 --- a/preferencesdialog.cpp +++ b/preferencesdialog.cpp @@ -102,8 +102,6 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) : //i=ui->timeZoneCombo->findText((*profile)["TimeZone"].toString()); //ui->timeZoneCombo->setCurrentIndex(i); - bool ok; - double v; ui->spo2Drop->setValue(profile->oxi->spO2DropPercentage()); ui->spo2DropTime->setValue(profile->oxi->spO2DropDuration()); ui->pulseChange->setValue(profile->oxi->pulseChangeBPM()); @@ -115,13 +113,13 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) : ui->combineSlider->setValue(val); if (val>0) { ui->combineLCD->display(val); - } else ui->combineLCD->display(tr("OFF")); + } else ui->combineLCD->display(STR_GEN_Off); val=profile->session->ignoreShortSessions(); ui->IgnoreSlider->setValue(val); if (val>0) { ui->IgnoreLCD->display(val); - } else ui->IgnoreLCD->display(tr("OFF")); + } else ui->IgnoreLCD->display(STR_GEN_Off); ui->applicationFont->setCurrentFont(QApplication::font()); //ui->applicationFont->setFont(QApplication::font()); @@ -179,12 +177,12 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) : ui->graphHeight->setValue(profile->appearance->graphHeight()); - if (!PREF.Exists("Updates_AutoCheck")) PREF["Updates_AutoCheck"]=true; - ui->automaticallyCheckUpdates->setChecked(PREF["Updates_AutoCheck"].toBool()); + if (!PREF.contains(STR_GEN_UpdatesAutoCheck)) PREF[STR_GEN_UpdatesAutoCheck]=true; + ui->automaticallyCheckUpdates->setChecked(PREF[STR_GEN_UpdatesAutoCheck].toBool()); - if (!PREF.Exists("Updates_CheckFrequency")) PREF["Updates_CheckFrequency"]=3; - ui->updateCheckEvery->setValue(PREF["Updates_CheckFrequency"].toInt()); - if (PREF.Exists("Updates_LastChecked")) { + if (!PREF.contains(STR_GEN_UpdateCheckFrequency)) PREF[STR_GEN_UpdateCheckFrequency]=3; + ui->updateCheckEvery->setValue(PREF[STR_GEN_UpdateCheckFrequency].toInt()); + if (PREF.contains(STR_GEN_UpdatesLastChecked)) { RefreshLastChecked(); } else ui->updateLastChecked->setText("Never"); @@ -335,10 +333,10 @@ void PreferencesDialog::Save() profile->oxi->setPulseChangeDuration(ui->pulseChangeTime->value()); profile->oxi->setOxiDiscardThreshold(ui->oxiDiscardThreshold->value()); - PREF["SkipLoginScreen"]=ui->skipLoginScreen->isChecked(); + PREF[STR_GEN_SkipLogin]=ui->skipLoginScreen->isChecked(); - PREF["Updates_AutoCheck"]=ui->automaticallyCheckUpdates->isChecked(); - PREF["Updates_CheckFrequency"]=ui->updateCheckEvery->value(); + PREF[STR_GEN_UpdatesAutoCheck]=ui->automaticallyCheckUpdates->isChecked(); + PREF[STR_GEN_UpdateCheckFrequency]=ui->updateCheckEvery->value(); PREF["Fonts_Application_Name"]=ui->applicationFont->currentText(); PREF["Fonts_Application_Size"]=ui->applicationFontSize->value(); @@ -418,27 +416,25 @@ void PreferencesDialog::on_combineSlider_valueChanged(int position) { if (position>0) { ui->combineLCD->display(position); - } else ui->combineLCD->display(tr("OFF")); + } else ui->combineLCD->display(STR_GEN_Off); } void PreferencesDialog::on_IgnoreSlider_valueChanged(int position) { if (position>0) { ui->IgnoreLCD->display(position); - } else ui->IgnoreLCD->display(tr("OFF")); + } else ui->IgnoreLCD->display(STR_GEN_Off); } #include "mainwindow.h" extern MainWindow * mainwin; void PreferencesDialog::RefreshLastChecked() { - ui->updateLastChecked->setText(PREF["Updates_LastChecked"].toDateTime().toString(Qt::SystemLocaleLongDate)); + ui->updateLastChecked->setText(PREF[STR_GEN_UpdatesLastChecked].toDateTime().toString(Qt::SystemLocaleLongDate)); } void PreferencesDialog::on_checkForUpdatesButton_clicked() { - //mainwin->statusBar()->showMessage("Checking for Updates"); - //ui->updateLastChecked->setText("Checking for Updates"); mainwin->CheckForUpdates(); } @@ -595,7 +591,7 @@ void PreferencesDialog::resetGraphModel() it->setData(i,Qt::UserRole+2); items.push_back(it); - if (title!=tr("Event Flags")) { // ouchie.. Translations will cause problems here.. + if (title!=STR_TR_EventFlags) { it=new QStandardItem(QString::number((*gv)[i]->rec_miny,'f',1)); it->setEditable(true); diff --git a/profileselect.cpp b/profileselect.cpp index 51c9e29a..f05378aa 100644 --- a/profileselect.cpp +++ b/profileselect.cpp @@ -33,7 +33,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) : for (QHash::iterator p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) { name=p.key(); QStandardItem *item=new QStandardItem(*new QIcon(":/icons/moon.png"),name); - if (PREF.Exists("Profile") && (name==PREF["Profile"].toString())) { + if (PREF.contains(STR_GEN_Profile) && (name==PREF[STR_GEN_Profile].toString())) { sel=i; } item->setData(p.key()); @@ -53,7 +53,7 @@ ProfileSelect::ProfileSelect(QWidget *parent) : /*PREF["SkipLogin"]=false; if ((i==1) && PREF["SkipLogin"].toBool()) { if (!Profiles::profiles.contains(name)) - PREF["Profile"]=name; + PREF[STR_GEN_Profile]=name; QTimer::singleShot(0,this,SLOT(earlyExit())); hide(); } */ @@ -79,7 +79,7 @@ void ProfileSelect::editProfile() Profile *profile=Profiles::Get(name); if (!profile) return; bool reallyEdit=false; - if (profile->Exists("Password")) { + if (profile->user->hasPassword()) { QDialog dialog(this,Qt::Dialog); QLineEdit *e=new QLineEdit(&dialog); e->setEchoMode(QLineEdit::Password); @@ -93,16 +93,15 @@ void ProfileSelect::editProfile() do { e->setText(""); if (dialog.exec()!=QDialog::Accepted) break; - QByteArray ba=e->text().toUtf8(); tries++; - if (QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex()==(*profile)["Password"]) { + if (profile->user->checkPassword(e->text())) { reallyEdit=true; break; } else { if (tries<3) { - QMessageBox::warning(this,tr("Error"),tr("Incorrect Password"),QMessageBox::Ok); + QMessageBox::warning(this,STR_MESSAGE_ERROR,tr("Incorrect Password"),QMessageBox::Ok); } else { - QMessageBox::warning(this,tr("Error"),tr("You entered the password wrong too many times."),QMessageBox::Ok); + QMessageBox::warning(this,STR_MESSAGE_ERROR,tr("You entered the password wrong too many times."),QMessageBox::Ok); reject(); } } @@ -128,7 +127,7 @@ void ProfileSelect::deleteProfile() QMessageBox::warning(this,tr("WTH???"),tr("If you can read this you need to delete this profile directory manually (It's under Your Documents folder -> SleepApp -> Profiles -> [profile_name])"),QMessageBox::Ok); return; } - if (profile->Exists("Password")) { + if (profile->user->hasPassword()) { QDialog dialog(this,Qt::Dialog); QLineEdit *e=new QLineEdit(&dialog); e->setEchoMode(QLineEdit::Password); @@ -142,16 +141,15 @@ void ProfileSelect::deleteProfile() do { e->setText(""); if (dialog.exec()!=QDialog::Accepted) break; - QByteArray ba=e->text().toUtf8(); tries++; - if (QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex()==(*profile)["Password"]) { + if (profile->user->checkPassword(e->text())) { reallydelete=true; break; } else { if (tries<3) { - QMessageBox::warning(this,tr("Error"),tr("Incorrect Password"),QMessageBox::Ok); + QMessageBox::warning(this,STR_MESSAGE_ERROR,tr("Incorrect Password"),QMessageBox::Ok); } else { - QMessageBox::warning(this,tr("Error"),tr("Meheh... If your trying to delete because you forgot the password, your going the wrong way about it. Read the docs.\n\nSigned: Nasty Programmer"),QMessageBox::Ok); + QMessageBox::warning(this,STR_MESSAGE_ERROR,tr("Meheh... If your trying to delete because you forgot the password, your going the wrong way about it. Read the docs.\n\nSigned: Nasty Programmer"),QMessageBox::Ok); } } } while (tries<3); @@ -198,9 +196,9 @@ void ProfileSelect::on_listView_activated(const QModelIndex &index) QString name=index.data().toString(); Profile *profile=Profiles::profiles[name]; if (!profile) return; - if (!profile->Exists("Password")) { + if (!profile->user->hasPassword()) { m_selectedProfile=name; - PREF["Profile"]=name; + PREF[STR_GEN_Profile]=name; accept(); return; } else { @@ -215,18 +213,17 @@ void ProfileSelect::on_listView_activated(const QModelIndex &index) dialog.setLayout(lay); lay->addWidget(e); dialog.exec(); - QByteArray ba=e->text().toUtf8(); - if (QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex()==(*profile)["Password"]) { + if (profile->user->checkPassword(e->text())) { m_selectedProfile=name; - PREF["Profile"]=name; + PREF[STR_GEN_Profile]=name; accept(); return; } tries++; if (tries<3) { - QMessageBox::warning(this,tr("Error"),tr("Incorrect Password"),QMessageBox::Ok); + QMessageBox::warning(this,STR_MESSAGE_ERROR,tr("Incorrect Password"),QMessageBox::Ok); } else { - QMessageBox::warning(this,tr("Error"),tr("You entered an Incorrect Password too many times. Exiting!"),QMessageBox::Ok); + QMessageBox::warning(this,STR_MESSAGE_ERROR,tr("You entered an Incorrect Password too many times. Exiting!"),QMessageBox::Ok); } } while (tries<3); }
"+tr("Pressure Relief:")+" "+flexstr+"
"+tr("Humidifier Setting:")+" "+humid+"
"+tr("EPR Setting:")+" "+QString::number(epr)+" / "+QString::number(epr2)+"