From f5d737bffe5351ef755bc91f6697da9c4bd2e101 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Wed, 5 Oct 2011 17:41:56 +1000 Subject: [PATCH] Changed all user preferences to actual per-user profile preferences --- Graphs/gGraphView.cpp | 8 ++--- Graphs/gLineChart.cpp | 3 +- Graphs/gLineOverlay.cpp | 4 +-- Graphs/gSessionTime.cpp | 2 +- Graphs/gSummaryChart.cpp | 17 ++++------ Graphs/gSummaryChart.h | 4 +-- SleepLib/machine.cpp | 14 ++++----- SleepLib/profiles.cpp | 18 ++++++----- SleepLib/profiles.h | 9 +++--- SleepLib/schema.h | 2 +- daily.cpp | 39 ++++++++++++----------- daily.h | 3 +- main.cpp | 11 +++---- mainwindow.cpp | 68 ++++++++++++++++++++++------------------ mainwindow.h | 4 ++- overview.cpp | 32 +++++++++---------- overview.h | 3 +- oximetry.cpp | 14 ++++----- oximetry.h | 3 +- preferencesdialog.cpp | 40 +++++++++++------------ profileselect.cpp | 18 +++++------ report.cpp | 27 +++++++--------- report.h | 3 +- 23 files changed, 169 insertions(+), 177 deletions(-) diff --git a/Graphs/gGraphView.cpp b/Graphs/gGraphView.cpp index 7935d9fd..2b996634 100644 --- a/Graphs/gGraphView.cpp +++ b/Graphs/gGraphView.cpp @@ -194,7 +194,7 @@ if (m_cnt0) { - bool antialias=m_forceantialias || (pref["UseAntiAliasing"].toBool() && m_antialias); + bool antialias=m_forceantialias || (PROFILE["UseAntiAliasing"].toBool() && m_antialias); float size=m_size; if (antialias) { glEnable(GL_BLEND); @@ -415,7 +415,7 @@ void GLFloatBuffer::draw() { if (m_cnt<=0) return; - bool antialias=m_forceantialias || (pref["UseAntiAliasing"].toBool() && m_antialias); + bool antialias=m_forceantialias || (PROFILE["UseAntiAliasing"].toBool() && m_antialias); float size=m_size; if (antialias) { glEnable(GL_BLEND); @@ -1848,7 +1848,7 @@ void gGraphView::paintGL() bool threaded; // Tempory hack using this pref.. - /*if (pref["EnableMultithreading"].toBool()) { // && (m_idealthreads>1)) { + /*if ((*profile)["EnableMultithreading"].toBool()) { // && (m_idealthreads>1)) { threaded=true; for (int i=0;iisRunning()) @@ -1926,7 +1926,7 @@ void gGraphView::paintGL() quads->draw(); DrawTextQue(); m_tooltip->paint(); - if (m_showsplitter && pref["ShowDebug"].toBool()) { + if (m_showsplitter && PROFILE["ShowDebug"].toBool()) { QString ss; ss="PreDraw took "+QString::number(elapsed)+"ms"; AddTextQue(ss,width()-140,10,0,col,defaultfont); diff --git a/Graphs/gLineChart.cpp b/Graphs/gLineChart.cpp index 6251ee9b..0c2ad4e2 100644 --- a/Graphs/gLineChart.cpp +++ b/Graphs/gLineChart.cpp @@ -30,8 +30,9 @@ void gLineChart::SetDay(Day *d) { Layer::SetDay(d); + if (m_code==CPAP_Leak) { - subtract_offset=pref["IntentionalLeak"].toDouble(); + subtract_offset=PROFILE["IntentionalLeak"].toDouble(); } else subtract_offset=0; diff --git a/Graphs/gLineOverlay.cpp b/Graphs/gLineOverlay.cpp index 33e8c6b3..5ee99093 100644 --- a/Graphs/gLineOverlay.cpp +++ b/Graphs/gLineOverlay.cpp @@ -83,7 +83,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh quads->add(x1,start_py,x2,start_py,x2,start_py+height,x1,start_py+height); if (quads->full()) { verts_exceeded=true; break; } } else if (m_flt==FT_Dot) { - if ((pref["AlwaysShowOverlayBars"].toInt()==0) || (xx<3600000)) { + if ((PROFILE["AlwaysShowOverlayBars"].toInt()==0) || (xx<3600000)) { // show the fat dots in the middle points->add(x1,double(height)/double(yy)*double(-20-w.min_y)+topp); if (points->full()) { verts_exceeded=true; break; } @@ -95,7 +95,7 @@ void gLineOverlayBar::paint(gGraph & w, int left, int topp, int width, int heigh } } else if (m_flt==FT_Bar) { int z=start_py+height; - if ((pref["AlwaysShowOverlayBars"].toInt()==0) || (xx<3600000)) { + if ((PROFILE["AlwaysShowOverlayBars"].toInt()==0) || (xx<3600000)) { z=top; points->add(x1,top); diff --git a/Graphs/gSessionTime.cpp b/Graphs/gSessionTime.cpp index 137c8178..e45617e4 100644 --- a/Graphs/gSessionTime.cpp +++ b/Graphs/gSessionTime.cpp @@ -65,7 +65,7 @@ void gSessionTime::paint(gGraph & w,int left, int top, int width, int height) QColor col2("light grey"); QString str; bool draw_xticks_instead=false; - bool antialias=pref["UseAntiAliasing"].toBool(); + bool antialias=(*profile)["UseAntiAliasing"].toBool(); QDateTime d; QTime t; diff --git a/Graphs/gSummaryChart.cpp b/Graphs/gSummaryChart.cpp index 9a348872..137a4e9e 100644 --- a/Graphs/gSummaryChart.cpp +++ b/Graphs/gSummaryChart.cpp @@ -11,8 +11,8 @@ #include "gSummaryChart.h" extern QLabel * qstatus2; -SummaryChart::SummaryChart(Profile *p,QString label,GraphType type) -:Layer(""),m_profile(p),m_label(label),m_graphtype(type) +SummaryChart::SummaryChart(QString label,GraphType type) +:Layer(""),m_label(label),m_graphtype(type) { QColor color=Qt::black; addGLBuf(quads=new GLShortBuffer(20000,GL_QUADS)); @@ -29,11 +29,6 @@ SummaryChart::~SummaryChart() } void SummaryChart::SetDay(Day * nullday) { - if (!m_profile) { - qWarning() << "Forgot to set profile for gBarChart dummy!"; - m_day=NULL; - return; - } Day * day=nullday; Layer::SetDay(day); @@ -53,7 +48,7 @@ void SummaryChart::SetDay(Day * nullday) m_empty=true; int suboffset; SummaryType type; - for (QMap >::iterator d=m_profile->daylist.begin();d!=m_profile->daylist.end();d++) { + for (QMap >::iterator d=PROFILE.daylist.begin();d!=PROFILE.daylist.end();d++) { tt=QDateTime(d.key(),QTime(0,0,0),Qt::UTC).toTime_t(); //tt=QDateTime(d.key(),QTime(12,0,0)).toTime_t(); dn=tt/86400; @@ -66,7 +61,7 @@ void SummaryChart::SetDay(Day * nullday) bool fnd=false; for (int j=0;jFirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; - m_maxx=qint64(QDateTime(m_profile->LastDay().addDays(1),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; + // m_minx=qint64(QDateTime(PROFILE.FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; + m_maxx=qint64(QDateTime(PROFILE.LastDay().addDays(1),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; } diff --git a/Graphs/gSummaryChart.h b/Graphs/gSummaryChart.h index fc5b4fcf..7ead41ac 100644 --- a/Graphs/gSummaryChart.h +++ b/Graphs/gSummaryChart.h @@ -16,10 +16,9 @@ enum GraphType { GT_BAR, GT_LINE }; class SummaryChart:public Layer { public: - SummaryChart(Profile *profile, QString label, GraphType type=GT_BAR); + SummaryChart(QString label, GraphType type=GT_BAR); virtual ~SummaryChart(); - void setProfile(Profile *profile) { m_profile=profile; } virtual void paint(gGraph & w,int left, int top, int width, int height); virtual void SetDay(Day * day=NULL); virtual bool isEmpty() { return m_empty; } @@ -36,7 +35,6 @@ class SummaryChart:public Layer QHash > m_values; QHash m_days; - Profile * m_profile; GLShortBuffer *quads,*lines; bool m_empty; int m_fday; diff --git a/SleepLib/machine.cpp b/SleepLib/machine.cpp index ef683ac1..d816831a 100644 --- a/SleepLib/machine.cpp +++ b/SleepLib/machine.cpp @@ -75,17 +75,17 @@ Day *Machine::AddSession(Session *s,Profile *p) QTime split_time(12,0,0); - if (pref.Exists("DaySplitTime")) { - split_time=pref["DaySplitTime"].toTime(); + if (PROFILE.Exists("DaySplitTime")) { + split_time=PROFILE["DaySplitTime"].toTime(); } int combine_sessions; - if (pref.Exists("CombineCloserSessions")) { - combine_sessions=pref["CombineCloserSessions"].toInt(); // In Minutes + if (PROFILE.Exists("CombineCloserSessions")) { + combine_sessions=PROFILE["CombineCloserSessions"].toInt(); // In Minutes } else combine_sessions=0; int ignore_sessions; - if (pref.Exists("IgnoreShorterSessions")) { - ignore_sessions=pref["IgnoreShorterSessions"].toInt(); // In Minutes + if (PROFILE.Exists("IgnoreShorterSessions")) { + ignore_sessions=PROFILE["IgnoreShorterSessions"].toInt(); // In Minutes } else ignore_sessions=0; int session_length=s->last()-s->first(); @@ -357,7 +357,7 @@ bool Machine::Save() } savelistCnt=0; savelistSize=m_savelist.size(); - if (!pref["EnableMultithreading"].toBool()) { + if (!PROFILE["EnableMultithreading"].toBool()) { for (int i=0;isetValue(66.0+(float(savelistCnt)/float(savelistSize)*33.0)); QApplication::processEvents(); diff --git a/SleepLib/profiles.cpp b/SleepLib/profiles.cpp index b2168c52..988a61a6 100644 --- a/SleepLib/profiles.cpp +++ b/SleepLib/profiles.cpp @@ -20,12 +20,13 @@ License: GPL Preferences *p_pref; Preferences *p_layout; +Profile * p_profile; Profile::Profile() :Preferences(),is_first_day(true) { p_name="Profile"; - p_path=pref.Get("{home}/Profiles"); + p_path=PREF.Get("{home}/Profiles"); machlist.clear(); //m_first=m_last= } @@ -60,7 +61,7 @@ void Profile::DataFormatError(Machine *m) if (QMessageBox::warning(NULL,"Machine Database Changes",msg,QMessageBox::Yes | QMessageBox::Cancel,QMessageBox::Yes)==QMessageBox::Yes) { if (!m->Purge(3478216)) { // Do not copy this line without thinking.. You will be eaten by a Grue if you do - QMessageBox::critical(NULL,"Purge Failed","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,"Purge Failed","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); exit(-1); } } else { @@ -301,8 +302,9 @@ QHash profiles; void Done() { - pref.Save(); - laypref.Save(); + PREF.Save(); + LAYOUT.Save(); + // Only save the open profile.. for (QHash::iterator i=profiles.begin(); i!=profiles.end(); i++) { i.value()->Save(); delete i.value(); @@ -321,7 +323,7 @@ Profile *Get(QString name) } Profile *Create(QString name) { - QString path=pref.Get("{home}/Profiles/")+name; + QString path=PREF.Get("{home}/Profiles/")+name; QDir dir(path); if (!dir.exists(path)) dir.mkpath(path); //path+="/"+name; @@ -362,10 +364,10 @@ void Scan() p_pref=new Preferences("Preferences"); p_layout=new Preferences("Layout"); - pref.Open(); - laypref.Open(); + PREF.Open(); + LAYOUT.Open(); - QString path=pref.Get("{home}/Profiles"); + QString path=PREF.Get("{home}/Profiles"); QDir dir(path); if (!dir.exists(path)) { diff --git a/SleepLib/profiles.h b/SleepLib/profiles.h index f01c47ec..6ba0c290 100644 --- a/SleepLib/profiles.h +++ b/SleepLib/profiles.h @@ -63,13 +63,12 @@ extern MachineLoader * GetLoader(QString name); extern Preferences *p_pref; extern Preferences *p_layout; +extern Profile * p_profile; // these are bad and must change -#define pref (*p_pref) -#define laypref (*p_layout) - - -extern Profile *profile; +#define PREF (*p_pref) +#define LAYOUT (*p_layout) +#define PROFILE (*p_profile) namespace Profiles { diff --git a/SleepLib/schema.h b/SleepLib/schema.h index e15c252c..967fd3fd 100644 --- a/SleepLib/schema.h +++ b/SleepLib/schema.h @@ -167,7 +167,7 @@ public: Graph(QString name,quint32 flags=GraphFlags::XTicker | GraphFlags::YTicker | GraphFlags::XGrid); Layer *addLayer(Layer *layer) { m_layers.push_back(layer); return layer; } int height() { if (m_visible) return m_height; else return 0;} - int setHeight(int h) { m_height=h; } + void setHeight(int h) { m_height=h; } bool visible() { return m_visible; } void setVisible(bool b) { m_visible=b; } protected: diff --git a/daily.cpp b/daily.cpp index 3b16482e..049027e1 100644 --- a/daily.cpp +++ b/daily.cpp @@ -18,6 +18,7 @@ #include #include +#include "SleepLib/profiles.h" #include "SleepLib/session.h" #include "Graphs/graphdata_custom.h" #include "Graphs/gLineOverlay.h" @@ -30,8 +31,8 @@ const int min_height=150; -Daily::Daily(QWidget *parent,Profile * _profile,gGraphView * shared, MainWindow *mw) - :QWidget(parent),mainwin(mw), ui(new Ui::Daily),profile(_profile) +Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw) + :QWidget(parent),mainwin(mw), ui(new Ui::Daily) { ui->setupUi(this); @@ -216,7 +217,7 @@ Daily::~Daily() void Daily::ReloadGraphs() { - QDate d=profile->LastDay(); + QDate d=PROFILE.LastDay(); if (!d.isValid()) { d=ui->calendar->selectedDate(); } @@ -317,8 +318,8 @@ void Daily::UpdateCalendarDay(QDate date) cpapcol.setFontWeight(QFont::Bold); oxiday.setForeground(QBrush(Qt::red, Qt::SolidPattern)); oxiday.setFontWeight(QFont::Bold); - bool hascpap=profile->GetDay(date,MT_CPAP)!=NULL; - bool hasoxi=profile->GetDay(date,MT_OXIMETER)!=NULL; + bool hascpap=PROFILE.GetDay(date,MT_CPAP)!=NULL; + bool hasoxi=PROFILE.GetDay(date,MT_OXIMETER)!=NULL; if (hascpap) { if (hasoxi) { @@ -326,7 +327,7 @@ void Daily::UpdateCalendarDay(QDate date) } else { ui->calendar->setDateTextFormat(date,cpapcol); } - } else if (profile->GetDay(date)) { + } else if (PROFILE.GetDay(date)) { ui->calendar->setDateTextFormat(date,bold); } else { ui->calendar->setDateTextFormat(date,normal); @@ -375,11 +376,11 @@ void Daily::Load(QDate date) { static Day * lastcpapday=NULL; previous_date=date; - Day *cpap=profile->GetDay(date,MT_CPAP); - Day *oxi=profile->GetDay(date,MT_OXIMETER); + Day *cpap=PROFILE.GetDay(date,MT_CPAP); + Day *oxi=PROFILE.GetDay(date,MT_OXIMETER); // Day *sleepstage=profile->GetDay(date,MT_SLEEPSTAGE); - if (!pref["MemoryHog"].toBool()) { + if (!PROFILE["MemoryHog"].toBool()) { if (lastcpapday && (lastcpapday!=cpap)) { for (QVector::iterator s=lastcpapday->begin();s!=lastcpapday->end();s++) { (*s)->TrashEvents(); @@ -453,7 +454,7 @@ void Daily::Load(QDate date) 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 (pref.Exists("ShowSerialNumbers") && pref["ShowSerialNumbers"].toBool()) { + if (PROFILE.Exists("ShowSerialNumbers") && PROFILE["ShowSerialNumbers"].toBool()) { html+=""+cpap->machine->properties["Serial"]+"\n"; } @@ -500,7 +501,7 @@ void Daily::Load(QDate date) // as it only relates to text drawing, which the Pie chart does not do // ^^ Scratch that.. pie now includes text.. - if (pref["EnableGraphSnapshots"].toBool()) { // AHI Pie Chart + if (PROFILE["EnableGraphSnapshots"].toBool()) { // AHI Pie Chart if (ahi+rei+fli>0) { html+="\n"; //"+tr("Event Breakdown")+"\n"; //G_AHI->setFixedSize(gwwidth,120); @@ -535,7 +536,7 @@ void Daily::Load(QDate date) ChannelID code=chans[i]; if (cpap && cpap->channelHasData(code)) { - if (code==CPAP_Leak) suboffset=pref["IntentionalLeak"].toDouble(); else suboffset=0; + if (code==CPAP_Leak) suboffset=PROFILE["IntentionalLeak"].toDouble(); else suboffset=0; html+=""+schema::channel[code].label(); html+=""+a.sprintf("%.2f",cpap->min(code)-suboffset); html+=""+a.sprintf("%.2f",cpap->wavg(code)-suboffset); @@ -562,7 +563,7 @@ void Daily::Load(QDate date) html+="\n"; if (cpap) { - // if (pref["EnableGraphSnapshots"].toBool()) { + // if ((*profile)["EnableGraphSnapshots"].toBool()) { /* if (cpap->channelExists(CPAP_Pressure)) { html+=("\n"); TAP->setFixedSize(gwwidth,30); @@ -643,7 +644,7 @@ void Daily::Unload(QDate date) } if (journal) { - Machine *jm=profile->GetMachine(MT_JOURNAL); + Machine *jm=PROFILE.GetMachine(MT_JOURNAL); if (jm) jm->SaveSession(journal); } UpdateCalendarDay(date); @@ -726,13 +727,13 @@ void Daily::on_JournalNotesColour_clicked() } Session * Daily::CreateJournalSession(QDate date) { - Machine *m=profile->GetMachine(MT_JOURNAL); + Machine *m=PROFILE.GetMachine(MT_JOURNAL); if (!m) { - m=new Machine(profile,0); + m=new Machine(p_profile,0); m->SetClass("Journal"); m->properties["Brand"]="Virtual"; m->SetType(MT_JOURNAL); - profile->AddMachine(m); + PROFILE.AddMachine(m); } Session *sess=new Session(m,0); QDateTime dt(date,QTime(17,0)); @@ -742,12 +743,12 @@ Session * Daily::CreateJournalSession(QDate date) dt=dt.addSecs(3600); sess->set_last(qint64(dt.toTime_t())*1000L); sess->SetChanged(true); - m->AddSession(sess,profile); + m->AddSession(sess,p_profile); return sess; } Session * Daily::GetJournalSession(QDate date) // Get the first journal session { - Day *journal=profile->GetDay(date,MT_JOURNAL); + Day *journal=PROFILE.GetDay(date,MT_JOURNAL); if (!journal) return NULL; //CreateJournalSession(date); QVector::iterator s; diff --git a/daily.h b/daily.h index dad5ebbc..871db843 100644 --- a/daily.h +++ b/daily.h @@ -35,7 +35,7 @@ class Daily : public QWidget Q_OBJECT public: - explicit Daily(QWidget *parent, Profile * _profile, gGraphView *shared,MainWindow *mw); + explicit Daily(QWidget *parent, gGraphView *shared,MainWindow *mw); ~Daily(); void ReloadGraphs(); void ResetGraphLayout(); @@ -85,7 +85,6 @@ private: MainWindow * mainwin; Ui::Daily *ui; - Profile *profile; QDate previous_date; //QScrollArea *scrollArea; //QVBoxLayout *splitter; diff --git a/main.cpp b/main.cpp index 435c6109..4dc4edc0 100644 --- a/main.cpp +++ b/main.cpp @@ -22,12 +22,10 @@ #include "SleepLib/loader_plugins/zeo_loader.h" #include "SleepLib/loader_plugins/resmed_loader.h" - #ifdef Q_WS_X11 #include #endif - MainWindow *mainwin=NULL; void MyOutputHandler(QtMsgType type, const char *msg) { @@ -74,7 +72,7 @@ int main(int argc, char *argv[]) ZEOLoader::Register(); ResmedLoader::Register(); Profiles::Scan(); - pref["AppName"]="SleepyHead"; + PREF["AppName"]="SleepyHead"; QString Version=QString("%1.%2.%3").arg(major_version).arg(minor_version).arg(revision_number); @@ -86,8 +84,8 @@ int main(int argc, char *argv[]) // Show New User wizard.. } else { - if (pref.Exists("VersionString")) { - QString V=pref["VersionString"].toString(); + if (PREF.Exists("VersionString")) { + QString V=PREF["VersionString"].toString(); if (V!=Version) { QMessageBox::warning(0,"New Version Warning","This is a new version of SleepyHead. If you experience a crash right after clicking Ok, you will need to manually delete the SleepApp folder (it's located in your Documents folder) and reimport your data. After this things should work normally.",QMessageBox::Ok); } @@ -97,7 +95,8 @@ int main(int argc, char *argv[]) exit(1); } } - pref["VersionString"]=Version; + PREF["VersionString"]=Version; + p_profile=Profiles::Get(PREF["Profile"].toString()); //if (!pref.Exists("Profile")) pref["Profile"]=getUserName(); diff --git a/mainwindow.cpp b/mainwindow.cpp index d603fd98..66145be5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -28,6 +28,8 @@ QLabel *qstatus; QLabel *qstatus2; QStatusBar *qstatusbar; +extern Profile * profile; + void MainWindow::Log(QString s) { @@ -56,9 +58,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { + + Q_ASSERT(p_profile!=NULL); + logtime.start(); ui->setupUi(this); - this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3 (%4)").arg(major_version).arg(minor_version).arg(revision_number).arg(pref["Profile"].toString())); + this->setWindowTitle(tr("SleepyHead")+QString(" v%1.%2.%3 (%4)").arg(major_version).arg(minor_version).arg(revision_number).arg(PREF["Profile"].toString())); ui->tabWidget->setCurrentIndex(0); //move(0,0); overview=NULL; @@ -94,30 +99,32 @@ MainWindow::MainWindow(QWidget *parent) : ui->statusbar->addPermanentWidget(qprogress,1); ui->statusbar->addPermanentWidget(qstatus2,0); - if (!pref.Exists("ShowDebug")) pref["ShowDebug"]=true; - ui->actionDebug->setChecked(pref["ShowDebug"].toBool()); + if (!PROFILE.Exists("ShowDebug")) PROFILE["ShowDebug"]=true; + ui->actionDebug->setChecked(PROFILE["ShowDebug"].toBool()); - if (!pref["ShowDebug"].toBool()) { + if (!PROFILE["ShowDebug"].toBool()) { ui->logText->hide(); } // This speeds up the second part of importing craploads.. later it will speed up the first part too. - if (!pref.Exists("EnableMultithreading")) pref["EnableMultithreading"]=QThread::idealThreadCount()>1; - if (!pref.Exists("MemoryHog")) pref["MemoryHog"]=false; - if (!pref.Exists("EnableGraphSnapshots")) pref["EnableGraphSnapshots"]=false; - if (!pref.Exists("AlwaysShowOverlayBars")) pref["AlwaysShowOverlayBars"]=0; - if (!pref.Exists("UseAntiAliasing")) pref["UseAntiAliasing"]=false; - if (!pref.Exists("IntentionalLeak")) pref["IntentionalLeak"]=(double)0.0; - if (!pref.Exists("IgnoreShorterSessions")) pref["IgnoreShorterSessions"]=0; - if (!pref.Exists("CombineCloserSessions")) pref["CombineCloserSessions"]=0; - if (!pref.Exists("DaySplitTime")) pref["DaySplitTime"]=QTime(12,0,0,0); + if (!PROFILE.Exists("EnableMultithreading")) PROFILE["EnableMultithreading"]=QThread::idealThreadCount()>1; + if (!PROFILE.Exists("MemoryHog")) PROFILE["MemoryHog"]=false; + if (!PROFILE.Exists("EnableGraphSnapshots")) PROFILE["EnableGraphSnapshots"]=false; + if (!PROFILE.Exists("AlwaysShowOverlayBars")) PROFILE["AlwaysShowOverlayBars"]=0; + if (!PROFILE.Exists("UseAntiAliasing")) PROFILE["UseAntiAliasing"]=false; + if (!PROFILE.Exists("IntentionalLeak")) PROFILE["IntentionalLeak"]=(double)0.0; + if (!PROFILE.Exists("IgnoreShorterSessions")) PROFILE["IgnoreShorterSessions"]=0; + if (!PROFILE.Exists("CombineCloserSessions")) PROFILE["CombineCloserSessions"]=0; + if (!PROFILE.Exists("DaySplitTime")) PROFILE["DaySplitTime"]=QTime(12,0,0,0); //DateTime(QDate::currentDate(),QTime(12,0,0,0),Qt::UTC).time(); - //ui->actionUse_AntiAliasing->setChecked(pref["UseAntiAliasing"].toBool()); + //ui->actionUse_AntiAliasing->setChecked(PROFILE["UseAntiAliasing"].toBool()); first_load=true; + + // Using the dirty registry here. :( QSettings settings("Jedimark", "SleepyHead"); this->restoreGeometry(settings.value("MainWindow/geometry").toByteArray()); @@ -157,20 +164,19 @@ MainWindow::~MainWindow() void MainWindow::Startup() { - qDebug() << pref["AppName"].toString().toAscii()+" v"+pref["VersionString"].toString().toAscii() << "built with Qt"<< QT_VERSION_STR << "on" << __DATE__ << __TIME__; + qDebug() << PREF["AppName"].toString().toAscii()+" v"+PREF["VersionString"].toString().toAscii() << "built with Qt"<< QT_VERSION_STR << "on" << __DATE__ << __TIME__; qstatus->setText(tr("Loading Data")); qprogress->show(); //qstatusbar->showMessage(tr("Loading Data"),0); - profile=Profiles::Get(pref["Profile"].toString()); - Q_ASSERT(profile!=NULL); + // profile is a global variable set in main after login - profile->LoadMachineData(); + PROFILE.LoadMachineData(); - daily=new Daily(ui->tabWidget,profile,NULL,this); + daily=new Daily(ui->tabWidget,NULL,this); ui->tabWidget->insertTab(1,daily,tr("Daily")); - overview=new Overview(ui->tabWidget,profile,daily->SharedWidget()); + overview=new Overview(ui->tabWidget,daily->SharedWidget()); ui->tabWidget->insertTab(2,overview,tr("Overview")); if (daily) daily->ReloadGraphs(); @@ -201,7 +207,7 @@ void MainWindow::on_action_Import_Data_triggered() qprogress->setValue(0); qprogress->show(); qstatus->setText(tr("Importing Data")); - int c=profile->Import(dir); + int c=PROFILE.Import(dir); if (!c) { QMessageBox::warning(this,"Import Problem","Couldn't Find any Machine Data at this location:\n"+dir,QMessageBox::Ok); } @@ -216,7 +222,7 @@ void MainWindow::on_action_Import_Data_triggered() }*/ qDebug() << "Finished Importing data" << c; if (c) { - profile->Save(); + PROFILE.Save(); if (daily) daily->ReloadGraphs(); if (overview) overview->ReloadGraphs(); //qDebug() << "overview->ReloadGraphs();"; @@ -335,7 +341,7 @@ void MainWindow::on_action_About_triggered() void MainWindow::on_actionDebug_toggled(bool checked) { - pref["ShowDebug"]=checked; + PROFILE["ShowDebug"]=checked; if (checked) { ui->logText->show(); } else { @@ -351,7 +357,7 @@ void MainWindow::on_action_Reset_Graph_Layout_triggered() void MainWindow::on_action_Preferences_triggered() { - PreferencesDialog pd(this,profile); + PreferencesDialog pd(this,p_profile); if (pd.exec()==PreferencesDialog::Accepted) { qDebug() << "Preferences Accepted"; pd.Save(); @@ -370,11 +376,11 @@ void MainWindow::on_oximetryButton_clicked() { bool first=false; if (!oximetry) { - if (!pref.Exists("HaveCMS50") || !pref["HaveCMS50"].toBool()) { + if (!PROFILE.Exists("HaveCMS50") || !PROFILE["HaveCMS50"].toBool()) { if (QMessageBox::question(this,"Question","Do you have a CMS50[x] Oximeter?\nOne is required to use this section.\nNote: This section is not fully completed yet.",QMessageBox::Yes,QMessageBox::No)==QMessageBox::No) return; - pref["HaveCMS50"]=true; + PROFILE["HaveCMS50"]=true; } - oximetry=new Oximetry(ui->tabWidget,profile,daily->SharedWidget()); + oximetry=new Oximetry(ui->tabWidget,daily->SharedWidget()); ui->tabWidget->insertTab(3,oximetry,tr("Oximetry")); first=true; } @@ -399,12 +405,12 @@ void MainWindow::replyFinished(QNetworkReply * reply) QByteArray data=reply->readAll(); QString a=data; a=a.trimmed(); - if (a>pref["VersionString"].toString()) { + if (a>PREF["VersionString"].toString()) { if (QMessageBox::question(this,"New Version","A newer version of SleepyHead is available, v"+a+".\nWould you like to update?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::Yes) { QMessageBox::information(this,"Laziness Warning","I'd love to do it for you automatically, but it's not implemented yet.. :)",QMessageBox::Ok); } } else { - QMessageBox::information(this,"SleepyHead v"+pref["VersionString"].toString(),"You're already up to date!\nLatest version on sourceforge is v"+a,QMessageBox::Ok); + QMessageBox::information(this,"SleepyHead v"+PREF["VersionString"].toString(),"You're already up to date!\nLatest version on sourceforge is v"+a,QMessageBox::Ok); } } } else { @@ -423,7 +429,7 @@ void MainWindow::on_action_Screenshot_triggered() void MainWindow::DelayedScreenshot() { QPixmap pixmap = QPixmap::grabWindow(this->winId()); - QString a=pref.Get("{home}")+"/Screenshots"; + QString a=PREF.Get("{home}")+"/Screenshots"; QDir dir(a); if (!dir.exists()){ dir.mkdir(a); @@ -454,7 +460,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["Profile"].toString()); newprof.exec(); } diff --git a/mainwindow.h b/mainwindow.h index b0f3ed88..d8044fb8 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -20,6 +20,8 @@ const int major_version=0; const int minor_version=8; const int revision_number=6; +extern Profile * profile; + namespace Ui { class MainWindow; } @@ -96,7 +98,7 @@ private: Overview * overview; Oximetry * oximetry; bool first_load; - Profile *profile; + //Profile *profile; QNetworkAccessManager *netmanager; QMutex loglock,strlock; diff --git a/overview.cpp b/overview.cpp index dce6ba7b..5a03b5a3 100644 --- a/overview.cpp +++ b/overview.cpp @@ -11,21 +11,19 @@ #include #include #include +#include "SleepLib/profiles.h" #include "overview.h" #include "ui_overview.h" #include "Graphs/gXAxis.h" #include "Graphs/gLineChart.h" #include "Graphs/gYAxis.h" -Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : +Overview::Overview(QWidget *parent,gGraphView * shared) : QWidget(parent), ui(new Ui::Overview), - profile(_profile), m_shared(shared) { ui->setupUi(this); - Q_ASSERT(profile!=NULL); - // Create dummy day & session for holding eventlists. //day=new Day(mach); @@ -57,7 +55,7 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : SET=new gGraph(GraphView,"Settings",default_height,0); LK=new gGraph(GraphView,"Leaks",default_height,0); - uc=new SummaryChart(profile,"Hours",GT_BAR); + uc=new SummaryChart("Hours",GT_BAR); uc->addSlice("",QColor("green"),ST_HOURS); UC->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); gXAxis *gx=new gXAxis(); @@ -67,7 +65,7 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : UC->AddLayer(new gXGrid()); - bc=new SummaryChart(profile,"AHI",GT_BAR); + bc=new SummaryChart("AHI",GT_BAR); bc->addSlice(CPAP_Hypopnea,QColor("blue"),ST_CPH); bc->addSlice(CPAP_Apnea,QColor("dark green"),ST_CPH); bc->addSlice(CPAP_Obstructive,QColor("#40c0ff"),ST_CPH); @@ -79,7 +77,7 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : AHI->AddLayer(bc); AHI->AddLayer(new gXGrid()); - set=new SummaryChart(profile,"",GT_LINE); + set=new SummaryChart("",GT_LINE); //set->addSlice("SysOneResistSet",QColor("grey"),ST_SETAVG); set->addSlice("HumidSet",QColor("blue"),ST_SETAVG); set->addSlice("FlexSet",QColor("red"),ST_SETAVG); @@ -93,7 +91,7 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : SET->AddLayer(set); SET->AddLayer(new gXGrid()); - pr=new SummaryChart(profile,"cmH2O",GT_LINE); + pr=new SummaryChart("cmH2O",GT_LINE); PR->forceMinY(4.0); //PR->forceMaxY(12.0); pr->addSlice(CPAP_Pressure,QColor("dark green"),ST_WAVG); @@ -110,7 +108,7 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : PR->AddLayer(pr); PR->AddLayer(new gXGrid()); - lk=new SummaryChart(profile,"Avg Leak",GT_LINE); + lk=new SummaryChart("Avg Leak",GT_LINE); lk->addSlice(CPAP_Leak,QColor("dark grey"),ST_90P); lk->addSlice(CPAP_Leak,QColor("dark blue"),ST_WAVG); //lk->addSlice(CPAP_Leak,QColor("dark yellow")); @@ -123,7 +121,7 @@ Overview::Overview(QWidget *parent,Profile * _profile,gGraphView * shared) : LK->AddLayer(new gXGrid()); NPB=new gGraph(GraphView,"% in PB",default_height,0); - NPB->AddLayer(npb=new SummaryChart(profile,"% PB",GT_BAR)); + NPB->AddLayer(npb=new SummaryChart("% PB",GT_BAR)); npb->addSlice(CPAP_CSR,QColor("light green"),ST_SPH); NPB->AddLayer(new gYAxis(),LayerLeft,gYAxis::Margin); gx=new gXAxis(); @@ -164,8 +162,8 @@ Overview::~Overview() } void Overview::ReloadGraphs() { - ui->dateStart->setDate(profile->FirstDay()); - ui->dateEnd->setDate(profile->LastDay()); + ui->dateStart->setDate(p_profile->FirstDay()); + ui->dateEnd->setDate(p_profile->LastDay()); GraphView->setDay(NULL); } @@ -187,8 +185,8 @@ void Overview::UpdateCalendarDay(QDateEdit * dateedit,QDate date) cpapcol.setFontWeight(QFont::Bold); oxiday.setForeground(QBrush(Qt::red, Qt::SolidPattern)); oxiday.setFontWeight(QFont::Bold); - bool hascpap=profile->GetDay(date,MT_CPAP)!=NULL; - bool hasoxi=profile->GetDay(date,MT_OXIMETER)!=NULL; + bool hascpap=PROFILE.GetDay(date,MT_CPAP)!=NULL; + bool hasoxi=PROFILE.GetDay(date,MT_OXIMETER)!=NULL; if (hascpap) { if (hasoxi) { @@ -196,7 +194,7 @@ void Overview::UpdateCalendarDay(QDateEdit * dateedit,QDate date) } else { calendar->setDateTextFormat(date,cpapcol); } - } else if (profile->GetDay(date)) { + } else if (p_profile->GetDay(date)) { calendar->setDateTextFormat(date,bold); } else { calendar->setDateTextFormat(date,normal); @@ -251,7 +249,7 @@ void Overview::on_toolButton_clicked() QString Overview::GetHTML() { if (!report) { - report=new Report(this,profile,m_shared,this); + report=new Report(this,m_shared,this); report->hide(); } @@ -281,7 +279,7 @@ void Overview::on_printButton_clicked() void Overview::on_htmlButton_clicked() { QString html=GetHTML(); - QString filename=QFileDialog::getSaveFileName(this,tr("Save HTML Report"),pref.Get("{home}"),tr("HTML Documents (*.html)")); + QString filename=QFileDialog::getSaveFileName(this,tr("Save HTML Report"),PREF.Get("{home}"),tr("HTML Documents (*.html)")); if (!filename.isEmpty()) { QFile file(filename); file.open(QIODevice::WriteOnly); diff --git a/overview.h b/overview.h index 52b3ea10..35aac3a9 100644 --- a/overview.h +++ b/overview.h @@ -26,7 +26,7 @@ class Overview : public QWidget Q_OBJECT public: - explicit Overview(QWidget *parent,Profile *profile, gGraphView *shared=NULL); + explicit Overview(QWidget *parent, gGraphView *shared=NULL); ~Overview(); void ReloadGraphs(); @@ -60,7 +60,6 @@ private slots: private: Ui::Overview *ui; - Profile *profile; gGraphView *GraphView; MyScrollBar *scrollbar; QHBoxLayout *layout; diff --git a/oximetry.cpp b/oximetry.cpp index d6b931a1..f6167490 100644 --- a/oximetry.cpp +++ b/oximetry.cpp @@ -13,23 +13,21 @@ #include "Graphs/gLineChart.h" #include "Graphs/gYAxis.h" -Oximetry::Oximetry(QWidget *parent,Profile * _profile,gGraphView * shared) : +Oximetry::Oximetry(QWidget *parent,gGraphView * shared) : QWidget(parent), - ui(new Ui::Oximetry), - profile(_profile) + ui(new Ui::Oximetry) { m_shared=shared; ui->setupUi(this); - Q_ASSERT(profile!=NULL); port=NULL; portname=""; - mach=profile->GetMachine(MT_OXIMETER); + mach=p_profile->GetMachine(MT_OXIMETER); if (!mach) { CMS50Loader *l=dynamic_cast(GetLoader("CMS50")); if (l) { - mach=l->CreateMachine(profile); + mach=l->CreateMachine(p_profile); } qDebug() << "Create Oximeter device"; } @@ -324,7 +322,7 @@ void Oximetry::on_RunButton_toggled(bool checked) sess->updateLast(sess->last(OXI_Plethy)); sess->SetChanged(true); - mach->AddSession(sess,profile); + mach->AddSession(sess,p_profile); mach->Save(); ev_plethy=session->AddEventList(OXI_Plethy,EVL_Waveform,1,0,0,0,1000.0/50.0); @@ -719,7 +717,7 @@ void Oximetry::on_ImportButton_clicked() session->wavg(OXI_SPO2); session->SetChanged(true); - mach->AddSession(session,profile); + mach->AddSession(session,p_profile); mach->Save(); // Output Pulse & SPO2 here.. delete [] buffer; diff --git a/oximetry.h b/oximetry.h index fce64a37..b99cf0b4 100644 --- a/oximetry.h +++ b/oximetry.h @@ -32,7 +32,7 @@ class Oximetry : public QWidget Q_OBJECT public: - explicit Oximetry(QWidget *parent, Profile * _profile,gGraphView * shared=NULL); + explicit Oximetry(QWidget *parent, gGraphView * shared=NULL); ~Oximetry(); void RedrawGraphs(); @@ -53,7 +53,6 @@ private: void UpdatePlethy(qint8 plethy); Ui::Oximetry *ui; - Profile *profile; gGraphView *GraphView; MyScrollBar *scrollbar; diff --git a/preferencesdialog.cpp b/preferencesdialog.cpp index d153f176..115b9379 100644 --- a/preferencesdialog.cpp +++ b/preferencesdialog.cpp @@ -19,30 +19,30 @@ PreferencesDialog::PreferencesDialog(QWidget *parent,Profile * _profile) : //i=ui->timeZoneCombo->findText((*profile)["TimeZone"].toString()); //ui->timeZoneCombo->setCurrentIndex(i); - QTime t=pref["DaySplitTime"].toTime(); + QTime t=(*profile)["DaySplitTime"].toTime(); ui->timeEdit->setTime(t); int val; - val=pref["CombineCloserSessions"].toInt(); + val=(*profile)["CombineCloserSessions"].toInt(); ui->combineSlider->setValue(val); if (val>0) { ui->combineLCD->display(val); } else ui->combineLCD->display(tr("OFF")); - val=pref["IgnoreShorterSessions"].toInt(); + val=(*profile)["IgnoreShorterSessions"].toInt(); ui->IgnoreSlider->setValue(val); if (val>0) { ui->IgnoreLCD->display(val); } else ui->IgnoreLCD->display(tr("OFF")); - ui->overlayFlagsCombo->setCurrentIndex(pref["AlwaysShowOverlayBars"].toInt()); - ui->useAntiAliasing->setChecked(pref["UseAntiAliasing"].toBool()); - ui->memoryHogCheckbox->setChecked(pref["MemoryHog"].toBool()); - ui->useGraphSnapshots->setChecked(pref["EnableGraphSnapshots"].toBool()); - ui->intentionalLeakEdit->setValue(pref["IntentionalLeak"].toDouble()); - ui->useMultithreading->setChecked(pref["EnableMultithreading"].toBool()); + ui->overlayFlagsCombo->setCurrentIndex((*profile)["AlwaysShowOverlayBars"].toInt()); + ui->useAntiAliasing->setChecked((*profile)["UseAntiAliasing"].toBool()); + ui->memoryHogCheckbox->setChecked((*profile)["MemoryHog"].toBool()); + ui->useGraphSnapshots->setChecked((*profile)["EnableGraphSnapshots"].toBool()); + ui->intentionalLeakEdit->setValue((*profile)["IntentionalLeak"].toDouble()); + ui->useMultithreading->setChecked((*profile)["EnableMultithreading"].toBool()); ui->eventTable->setColumnWidth(0,40); ui->eventTable->setColumnWidth(1,55); @@ -131,18 +131,18 @@ void PreferencesDialog::Save() (*profile)["UnitSystem"]=ui->unitCombo->currentText(); //(*profile)["TimeZone"]=ui->timeZoneCombo->currentText(); - pref["CombineCloserSessions"]=ui->combineSlider->value(); - pref["IgnoreShorterSessions"]=ui->IgnoreSlider->value(); + (*profile)["CombineCloserSessions"]=ui->combineSlider->value(); + (*profile)["IgnoreShorterSessions"]=ui->IgnoreSlider->value(); - pref["MemoryHog"]=ui->memoryHogCheckbox->isChecked(); - pref["DaySplitTime"]=ui->timeEdit->time(); + (*profile)["MemoryHog"]=ui->memoryHogCheckbox->isChecked(); + (*profile)["DaySplitTime"]=ui->timeEdit->time(); - pref["AlwaysShowOverlayBars"]=ui->overlayFlagsCombo->currentIndex(); - pref["UseAntiAliasing"]=ui->useAntiAliasing->isChecked(); - pref["MemoryHog"]=ui->memoryHogCheckbox->isChecked(); - pref["EnableGraphSnapshots"]=ui->useGraphSnapshots->isChecked(); - pref["IntentionalLeak"]=ui->intentionalLeakEdit->value(); - pref["EnableMultithreading"]=ui->useMultithreading->isChecked(); + (*profile)["AlwaysShowOverlayBars"]=ui->overlayFlagsCombo->currentIndex(); + (*profile)["UseAntiAliasing"]=ui->useAntiAliasing->isChecked(); + (*profile)["MemoryHog"]=ui->memoryHogCheckbox->isChecked(); + (*profile)["EnableGraphSnapshots"]=ui->useGraphSnapshots->isChecked(); + (*profile)["IntentionalLeak"]=ui->intentionalLeakEdit->value(); + (*profile)["EnableMultithreading"]=ui->useMultithreading->isChecked(); for (QHash::iterator i=m_new_colors.begin();i!=m_new_colors.end();i++) { schema::Channel &chan=schema::channel[i.key()]; @@ -154,7 +154,7 @@ void PreferencesDialog::Save() qDebug() << "TODO: Save channels.xml to update channel data"; profile->Save(); - pref.Save(); + PREF.Save(); } void PreferencesDialog::on_combineSlider_valueChanged(int position) diff --git a/profileselect.cpp b/profileselect.cpp index 7b50015b..723adf22 100644 --- a/profileselect.cpp +++ b/profileselect.cpp @@ -29,12 +29,12 @@ ProfileSelect::ProfileSelect(QWidget *parent) : QString name; for (QHash::iterator p=Profiles::profiles.begin();p!=Profiles::profiles.end();p++) { //str.append(p.key()); - Profile &profile=**p; + //Profile &profile=**p; name=p.key(); - // if (!profile["FirstName"].toString().isEmpty()) - // name+=" ("+profile["FirstName"].toString()+" "+profile["LastName"].toString()+")"; + // if (!PROFILE["FirstName"].toString().isEmpty()) + // name+=" ("+PROFILE["FirstName"].toString()+" "+PROFILE["LastName"].toString()+")"; QStandardItem *item=new QStandardItem(*new QIcon(":/icons/moon.png"),name); - if (pref.Exists("Profile") && (name==pref["Profile"].toString())) { + if (PREF.Exists("Profile") && (name==PREF["Profile"].toString())) { sel=i; } item->setData(p.key()); @@ -49,10 +49,10 @@ ProfileSelect::ProfileSelect(QWidget *parent) : if (sel>=0) ui->listView->setCurrentIndex(model->item(sel)->index()); m_tries=0; - pref["SkipLogin"]=false; - if ((i==1) && pref["SkipLogin"].toBool()) { + PREF["SkipLogin"]=false; + if ((i==1) && PREF["SkipLogin"].toBool()) { if (!Profiles::profiles.contains(name)) - pref["Profile"]=name; + PREF["Profile"]=name; QTimer::singleShot(0,this,SLOT(earlyExit())); hide(); } @@ -189,7 +189,7 @@ void ProfileSelect::on_listView_activated(const QModelIndex &index) if (!profile) return; if (!profile->Exists("Password")) { m_selectedProfile=name; - pref["Profile"]=name; + PREF["Profile"]=name; accept(); return; } else { @@ -207,7 +207,7 @@ void ProfileSelect::on_listView_activated(const QModelIndex &index) QByteArray ba=e->text().toUtf8(); if (QCryptographicHash::hash(ba,QCryptographicHash::Sha1).toHex()==(*profile)["Password"]) { m_selectedProfile=name; - pref["Profile"]=name; + PREF["Profile"]=name; accept(); return; } diff --git a/report.cpp b/report.cpp index 6b183e2f..3c025bf1 100644 --- a/report.cpp +++ b/report.cpp @@ -11,16 +11,13 @@ #include #include -Report::Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overview * overview) : +Report::Report(QWidget *parent, gGraphView * shared, Overview * overview) : QWidget(parent), ui(new Ui::Report), - profile(_profile), m_overview(overview) { ui->setupUi(this); - Q_ASSERT(profile!=NULL); - GraphView=new gGraphView(this,shared); setMaximumSize(graph_print_width,800); setMinimumSize(graph_print_width,800); @@ -78,8 +75,8 @@ void Report::ReloadGraphs() for (QHash::iterator g=graphs.begin();g!=graphs.end();g++) { g.value()->setDay(NULL); } - startDate=profile->FirstDay(); - endDate=profile->LastDay(); + startDate=PROFILE.FirstDay(); + endDate=PROFILE.LastDay(); for (QHash::iterator g=graphs.begin();g!=graphs.end();g++) { g.value()->ResetBounds(); } @@ -120,9 +117,9 @@ QString Report::ParseTemplate(QString input) QString key=block.section(".",1,-1); QHash * pr=NULL; if (code=="profile") { - pr=&profile->p_preferences; + pr=&PROFILE.p_preferences; } else if (code=="pref") { - pr=&pref.p_preferences; + pr=&PREF.p_preferences; } else if (code=="local") { pr=&locals; } @@ -189,7 +186,7 @@ QString Report::GenerateReport(QString templ,QDate start, QDate end) startDate=start; endDate=end; - QString filename=pref.Get("{home}/Reports"); + QString filename=PREF.Get("{home}/Reports"); QDir dir(filename); if (!dir.exists()) { dir.mkdir(filename); @@ -221,18 +218,18 @@ QString Report::GenerateReport(QString templ,QDate start, QDate end) locals["end"]=end; locals["width"]=graph_print_width-10; - if ((*profile).Exists("DOB") && !(*profile)["DOB"].toString().isEmpty()) { - QDate dob=(*profile)["DOB"].toDate(); + if (PROFILE.Exists("DOB") && !PROFILE["DOB"].toString().isEmpty()) { + QDate dob=PROFILE["DOB"].toDate(); QDateTime d1(dob,QTime(0,0,0)); QDateTime d2(QDate::currentDate(),QTime(0,0,0)); int years=d1.daysTo(d2)/365.25; locals["Age"]=years; } - if (!(*profile).Exists("UnitSystem")) { - (*profile)["UnitSystem"]="Metric"; + if (!PROFILE.Exists("UnitSystem")) { + PROFILE["UnitSystem"]="Metric"; } - if ((*profile).Exists("Height") && !(*profile)["Height"].toString().isEmpty()) { - if ((*profile)["UnitSystem"].toString()=="Metric") + if (PROFILE.Exists("Height") && !PROFILE["Height"].toString().isEmpty()) { + if (PROFILE["UnitSystem"].toString()=="Metric") locals["DistanceMeasure"]="cm"; else locals["DistanceMeasure"]=" inches"; } diff --git a/report.h b/report.h index 661975e8..9ce0502e 100644 --- a/report.h +++ b/report.h @@ -21,7 +21,7 @@ class Report : public QWidget Q_OBJECT public: - explicit Report(QWidget *parent, Profile * _profile, gGraphView * shared, Overview * overview); + explicit Report(QWidget *parent, gGraphView * shared, Overview * overview); ~Report(); QString GenerateReport(QString templ,QDate start, QDate end); void ReloadGraphs(); @@ -32,7 +32,6 @@ public: private: Ui::Report *ui; - Profile * profile; Overview * m_overview; gGraphView * shared; gGraphView * GraphView;
")+tr("Time@Pressure")+("