Standardize on a global profile object

This commit is contained in:
Mark Watkins 2014-07-11 07:09:38 -05:00
parent 422c4821f0
commit 083a667527
46 changed files with 438 additions and 470 deletions

View File

@ -209,7 +209,7 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion &region)
int idx; int idx;
QHash<ChannelID, QVector<EventList *> >::iterator cei; QHash<ChannelID, QVector<EventList *> >::iterator cei;
qint64 clockdrift = qint64(PROFILE.cpap->clockDrift()) * 1000L; qint64 clockdrift = qint64(p_profile->cpap->clockDrift()) * 1000L;
qint64 drift = 0; qint64 drift = 0;
QVector<QLine> vlines; QVector<QLine> vlines;

View File

@ -514,7 +514,7 @@ void gGraph::ToolTip(QString text, int x, int y, int timeout)
// YAxis Autoscaling code // YAxis Autoscaling code
void gGraph::roundY(EventDataType &miny, EventDataType &maxy) void gGraph::roundY(EventDataType &miny, EventDataType &maxy)
{ {
if ((zoomY() == 0) && PROFILE.appearance->allowYAxisScaling()) { if ((zoomY() == 0) && p_profile->appearance->allowYAxisScaling()) {
if (rec_maxy > rec_miny) { if (rec_maxy > rec_miny) {
// Use graph preference settings only for this graph // Use graph preference settings only for this graph
miny = rec_miny; miny = rec_miny;

View File

@ -348,7 +348,7 @@ gGraphView::~gGraphView()
bool gGraphView::usePixmapCache() bool gGraphView::usePixmapCache()
{ {
//use_pixmap_cache is an overide setting //use_pixmap_cache is an overide setting
return PROFILE.appearance->usePixmapCaching(); return p_profile->appearance->usePixmapCaching();
} }
#define CACHE_DRAWTEXT #define CACHE_DRAWTEXT
@ -359,7 +359,7 @@ void gGraphView::DrawTextQue(QPainter &painter)
int w, h; int w, h;
// not sure if global antialiasing would be better.. // not sure if global antialiasing would be better..
//painter.setRenderHint(QPainter::TextAntialiasing, PROFILE.appearance->antiAliasing()); //painter.setRenderHint(QPainter::TextAntialiasing, p_profile->appearance->antiAliasing());
int m_textque_items = m_textque.size(); int m_textque_items = m_textque.size();
for (int i = 0; i < m_textque_items; ++i) { for (int i = 0; i < m_textque_items; ++i) {
TextQue &q = m_textque[i]; TextQue &q = m_textque[i];
@ -617,7 +617,7 @@ void gGraphView::selectionTime()
if (d > 1) { if (d > 1) {
/*QDate d1=QDateTime::fromTime_t(m_minx/1000).toUTC().date(); /*QDate d1=QDateTime::fromTime_t(m_minx/1000).toUTC().date();
QDate d2=QDateTime::fromTime_t(m_maxx/1000).toUTC().date(); QDate d2=QDateTime::fromTime_t(m_maxx/1000).toUTC().date();
d=PROFILE.countDays(MT_CPAP,d1,d2); */ d=p_profile->countDays(MT_CPAP,d1,d2); */
str.sprintf("%1.0f days", ceil(d)); str.sprintf("%1.0f days", ceil(d));
} else { } else {
@ -664,7 +664,7 @@ void gGraphView::ResetBounds(bool refresh) //short group)
if (!m2 || m_graphs[i]->max_x > m2) { m2 = m_graphs[i]->max_x; } if (!m2 || m_graphs[i]->max_x > m2) { m2 = m_graphs[i]->max_x; }
} }
if (PROFILE.general->linkGroups()) { if (p_profile->general->linkGroups()) {
for (int i = 0; i < m_graphs.size(); i++) { for (int i = 0; i < m_graphs.size(); i++) {
m_graphs[i]->SetMinX(m1); m_graphs[i]->SetMinX(m1);
m_graphs[i]->SetMaxX(m2); m_graphs[i]->SetMaxX(m2);
@ -687,7 +687,7 @@ void gGraphView::ResetBounds(bool refresh) //short group)
if (d > 1) { if (d > 1) {
/*QDate d1=QDateTime::fromTime_t(m_minx/1000).toUTC().date(); /*QDate d1=QDateTime::fromTime_t(m_minx/1000).toUTC().date();
QDate d2=QDateTime::fromTime_t(m_maxx/1000).toUTC().date(); QDate d2=QDateTime::fromTime_t(m_maxx/1000).toUTC().date();
d=PROFILE.countDays(MT_CPAP,d1,d2); */ d=p_profile->countDays(MT_CPAP,d1,d2); */
str.sprintf("%1.0f days", ceil(d)); str.sprintf("%1.0f days", ceil(d));
} else { } else {
@ -710,7 +710,7 @@ void gGraphView::GetXBounds(qint64 &st, qint64 &et)
void gGraphView::SetXBounds(qint64 minx, qint64 maxx, short group, bool refresh) void gGraphView::SetXBounds(qint64 minx, qint64 maxx, short group, bool refresh)
{ {
for (int i = 0; i < m_graphs.size(); i++) { for (int i = 0; i < m_graphs.size(); i++) {
if (PROFILE.general->linkGroups() || (m_graphs[i]->group() == group)) { if (p_profile->general->linkGroups() || (m_graphs[i]->group() == group)) {
m_graphs[i]->SetXBounds(minx, maxx); m_graphs[i]->SetXBounds(minx, maxx);
} }
} }
@ -972,7 +972,7 @@ void gGraphView::paintGL()
redrawtimer->stop(); redrawtimer->stop();
} }
bool render_cube = false; //PROFILE.appearance->animations(); // do something to bool render_cube = false; //p_profile->appearance->animations(); // do something to
if (width() <= 0) { return; } if (width() <= 0) { return; }
if (height() <= 0) { return; } if (height() <= 0) { return; }
@ -1019,7 +1019,7 @@ void gGraphView::paintGL()
static int rp = 0; static int rp = 0;
// Show FPS and draw time // Show FPS and draw time
if (m_showsplitter && PROFILE.general->showDebug()) { if (m_showsplitter && p_profile->general->showDebug()) {
QString ss; QString ss;
qint64 ela = time.nsecsElapsed(); qint64 ela = time.nsecsElapsed();
double ms = double(ela) / 1000000.0; double ms = double(ela) / 1000000.0;
@ -1684,7 +1684,7 @@ void gGraphView::wheelEvent(QWheelEvent *event)
py += graphSpacer; // do we want the extra spacer down the bottom? py += graphSpacer; // do we want the extra spacer down the bottom?
} }
} else { } else {
int scrollDampening = PROFILE.general->scrollDampening(); int scrollDampening = p_profile->general->scrollDampening();
if (event->orientation() == Qt::Vertical) { // Vertical Scrolling if (event->orientation() == Qt::Vertical) { // Vertical Scrolling
if (horizScrollTime.elapsed() < scrollDampening) { if (horizScrollTime.elapsed() < scrollDampening) {
@ -1766,7 +1766,7 @@ void gGraphView::keyPressEvent(QKeyEvent *event)
if (event->key() == Qt::Key_PageUp) { if (event->key() == Qt::Key_PageUp) {
if (m_scrollbar) { if (m_scrollbar) {
m_offsetY -= PROFILE.appearance->graphHeight() * 3 * m_scaleY; m_offsetY -= p_profile->appearance->graphHeight() * 3 * m_scaleY;
m_scrollbar->setValue(m_offsetY); m_scrollbar->setValue(m_offsetY);
m_offsetY = m_scrollbar->value(); m_offsetY = m_scrollbar->value();
redraw(); redraw();
@ -1774,7 +1774,7 @@ void gGraphView::keyPressEvent(QKeyEvent *event)
return; return;
} else if (event->key() == Qt::Key_PageDown) { } else if (event->key() == Qt::Key_PageDown) {
if (m_scrollbar) { if (m_scrollbar) {
m_offsetY += PROFILE.appearance->graphHeight() * 3 * m_scaleY; //PROFILE.appearance->graphHeight(); m_offsetY += p_profile->appearance->graphHeight() * 3 * m_scaleY; //p_profile->appearance->graphHeight();
if (m_offsetY < 0) { m_offsetY = 0; } if (m_offsetY < 0) { m_offsetY = 0; }
@ -1898,7 +1898,7 @@ void gGraphView::timedRedraw(int ms)
} }
void gGraphView::resetLayout() void gGraphView::resetLayout()
{ {
int default_height = PROFILE.appearance->graphHeight(); int default_height = p_profile->appearance->graphHeight();
for (int i = 0; i < m_graphs.size(); i++) { for (int i = 0; i < m_graphs.size(); i++) {
m_graphs[i]->setHeight(default_height); m_graphs[i]->setHeight(default_height);
@ -1919,7 +1919,7 @@ const quint16 gvversion = 2;
void gGraphView::SaveSettings(QString title) void gGraphView::SaveSettings(QString title)
{ {
QString filename = PROFILE.Get("{DataFolder}/") + title.toLower() + ".shg"; QString filename = p_profile->Get("{DataFolder}/") + title.toLower() + ".shg";
QFile f(filename); QFile f(filename);
f.open(QFile::WriteOnly); f.open(QFile::WriteOnly);
QDataStream out(&f); QDataStream out(&f);
@ -1946,7 +1946,7 @@ void gGraphView::SaveSettings(QString title)
bool gGraphView::LoadSettings(QString title) bool gGraphView::LoadSettings(QString title)
{ {
QString filename = PROFILE.Get("{DataFolder}/") + title.toLower() + ".shg"; QString filename = p_profile->Get("{DataFolder}/") + title.toLower() + ".shg";
QFile f(filename); QFile f(filename);
if (!f.exists()) { return false; } if (!f.exists()) { return false; }

View File

@ -250,7 +250,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
int total_points = 0; int total_points = 0;
int total_visible = 0; int total_visible = 0;
bool square_plot, accel; bool square_plot, accel;
qint64 clockdrift = qint64(PROFILE.cpap->clockDrift()) * 1000L; qint64 clockdrift = qint64(p_profile->cpap->clockDrift()) * 1000L;
qint64 drift = 0; qint64 drift = 0;
QHash<ChannelID, QVector<EventList *> >::iterator ci; QHash<ChannelID, QVector<EventList *> >::iterator ci;
@ -262,7 +262,7 @@ void gLineChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
painter.setClipRect(left, top, width, height+1); painter.setClipRect(left, top, width, height+1);
painter.setClipping(true); painter.setClipping(true);
painter.setRenderHint(QPainter::Antialiasing, PROFILE.appearance->antiAliasing()); painter.setRenderHint(QPainter::Antialiasing, p_profile->appearance->antiAliasing());
for (int gi = 0; gi < m_codes.size(); gi++) { for (int gi = 0; gi < m_codes.size(); gi++) {

View File

@ -65,11 +65,11 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
EventStoreType *dptr, *eptr; EventStoreType *dptr, *eptr;
qint64 stime; qint64 stime;
OverlayDisplayType odt = PROFILE.appearance->overlayType(); OverlayDisplayType odt = p_profile->appearance->overlayType();
QHash<ChannelID, QVector<EventList *> >::iterator cei; QHash<ChannelID, QVector<EventList *> >::iterator cei;
int count; int count;
qint64 clockdrift = qint64(PROFILE.cpap->clockDrift()) * 1000L; qint64 clockdrift = qint64(p_profile->cpap->clockDrift()) * 1000L;
qint64 drift = 0; qint64 drift = 0;
// For each session, process it's eventlist // For each session, process it's eventlist

View File

@ -37,14 +37,14 @@ void gSessionTimesChart::SetDay(Day *unused_day)
Q_UNUSED(unused_day) Q_UNUSED(unused_day)
Layer::SetDay(nullptr); Layer::SetDay(nullptr);
QDate firstday = PROFILE.FirstDay(m_machtype); QDate firstday = p_profile->FirstDay(m_machtype);
QDate lastday = PROFILE.LastDay(m_machtype); QDate lastday = p_profile->LastDay(m_machtype);
m_minx = QDateTime(firstday, QTime(0,0,0)).toMSecsSinceEpoch(); m_minx = QDateTime(firstday, QTime(0,0,0)).toMSecsSinceEpoch();
m_maxx = QDateTime(lastday, QTime(23,59,59)).toMSecsSinceEpoch(); m_maxx = QDateTime(lastday, QTime(23,59,59)).toMSecsSinceEpoch();
// Get list of valid day records in supplied date range // Get list of valid day records in supplied date range
QList<Day *> daylist = PROFILE.getDays(m_machtype, firstday, lastday); QList<Day *> daylist = p_profile->getDays(m_machtype, firstday, lastday);
if (daylist.size() == 0) { if (daylist.size() == 0) {
m_miny = m_maxy = 0; m_miny = m_maxy = 0;

View File

@ -55,8 +55,8 @@ void SummaryChart::SetDay(Day * nullday)
int dn; int dn;
EventDataType tmp, tmp2, total; EventDataType tmp, tmp2, total;
ChannelID code; ChannelID code;
CPAPMode cpapmode = (CPAPMode)(int)PROFILE.calcSettingsMax(CPAP_Mode, MT_CPAP, CPAPMode cpapmode = (CPAPMode)(int)p_profile->calcSettingsMax(CPAP_Mode, MT_CPAP,
PROFILE.FirstDay(MT_CPAP), PROFILE.LastDay(MT_CPAP)); p_profile->FirstDay(MT_CPAP), p_profile->LastDay(MT_CPAP));
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
@ -68,8 +68,8 @@ void SummaryChart::SetDay(Day * nullday)
m_type.clear(); m_type.clear();
m_typeval.clear(); m_typeval.clear();
float perc = PROFILE.general->prefCalcPercentile() / 100.0; float perc = p_profile->general->prefCalcPercentile() / 100.0;
int mididx = PROFILE.general->prefCalcMiddle(); int mididx = p_profile->general->prefCalcMiddle();
SummaryType mid; SummaryType mid;
if (mididx == 0) { mid = ST_PERC; } if (mididx == 0) { mid = ST_PERC; }
@ -111,7 +111,7 @@ void SummaryChart::SetDay(Day * nullday)
if (m_graphtype == GT_SESSIONS) { if (m_graphtype == GT_SESSIONS) {
// No point drawing anything if no real data on record // No point drawing anything if no real data on record
if (PROFILE.countDays(MT_CPAP, PROFILE.FirstDay(MT_CPAP), PROFILE.LastDay(MT_CPAP)) == 0) { if (p_profile->countDays(MT_CPAP, p_profile->FirstDay(MT_CPAP), p_profile->LastDay(MT_CPAP)) == 0) {
return; return;
} }
} }
@ -123,7 +123,7 @@ void SummaryChart::SetDay(Day * nullday)
// For each day in the main profile daylist // For each day in the main profile daylist
QMap<QDate, QList<Day *> >::iterator d; QMap<QDate, QList<Day *> >::iterator d;
for (d = PROFILE.daylist.begin(); d != PROFILE.daylist.end(); d++) { for (d = p_profile->daylist.begin(); d != p_profile->daylist.end(); d++) {
// get the timestamp of this day. // get the timestamp of this day.
tt = QDateTime(d.key(), QTime(0, 0, 0), Qt::UTC).toTime_t(); tt = QDateTime(d.key(), QTime(0, 0, 0), Qt::UTC).toTime_t();
@ -378,8 +378,8 @@ void SummaryChart::SetDay(Day * nullday)
m_miny = 0; m_miny = 0;
} }
// m_minx=qint64(QDateTime(PROFILE.FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L; // m_minx=qint64(QDateTime(p_profile->FirstDay(),QTime(0,0,0),Qt::UTC).toTime_t())*1000L;
m_maxx = qint64(QDateTime(PROFILE.LastDay(), QTime(23, 59, 0), Qt::UTC).toTime_t()) * 1000L; m_maxx = qint64(QDateTime(p_profile->LastDay(), QTime(23, 59, 0), Qt::UTC).toTime_t()) * 1000L;
m_physmaxy = m_maxy; m_physmaxy = m_maxy;
m_physminy = m_miny; m_physminy = m_miny;
} }
@ -424,7 +424,7 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
GraphType graphtype = m_graphtype; GraphType graphtype = m_graphtype;
if (graphtype == GT_LINE || graphtype == GT_POINTS) { if (graphtype == GT_LINE || graphtype == GT_POINTS) {
bool pts = PROFILE.appearance->overviewLinechartMode() == OLC_Lines; bool pts = p_profile->appearance->overviewLinechartMode() == OLC_Lines;
graphtype = pts ? GT_POINTS : GT_LINE; graphtype = pts ? GT_POINTS : GT_LINE;
} }
@ -526,8 +526,8 @@ void SummaryChart::paint(QPainter &painter, gGraph &w, const QRegion &region)
float compliance_hours = 0; float compliance_hours = 0;
if (PROFILE.cpap->showComplianceInfo()) { if (p_profile->cpap->showComplianceInfo()) {
compliance_hours = PROFILE.cpap->complianceHours(); compliance_hours = p_profile->cpap->complianceHours();
} }
int incompliant = 0; int incompliant = 0;
@ -975,7 +975,7 @@ jumpnext:
}*/ }*/
a += QString(QObject::tr("Days: %1")).arg(total_days, 0); a += QString(QObject::tr("Days: %1")).arg(total_days, 0);
if (PROFILE.cpap->showComplianceInfo()) { if (p_profile->cpap->showComplianceInfo()) {
if (ishours && incompliant > 0) { if (ishours && incompliant > 0) {
a += " "+QString(QObject::tr("Low Usage Days: %1")).arg(incompliant, 0)+ a += " "+QString(QObject::tr("Low Usage Days: %1")).arg(incompliant, 0)+
" "+QString(QObject::tr("(%1% compliant, defined as > %2 hours)")). " "+QString(QObject::tr("(%1% compliant, defined as > %2 hours)")).
@ -1200,7 +1200,7 @@ bool SummaryChart::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
} else { v = 0; } } else { v = 0; }
if (m_codes[i] == Journal_Weight) { if (m_codes[i] == Journal_Weight) {
val = weightString(v, PROFILE.general->unitSystem()); val = weightString(v, p_profile->general->unitSystem());
} else { } else {
val = QString::number(v, 'f', 2); val = QString::number(v, 'f', 2);
} }

View File

@ -616,7 +616,7 @@ void FlowParser::calc(bool calcResp, bool calcTv, bool calcTi, bool calcTe, bool
void FlowParser::flagEvents() void FlowParser::flagEvents()
{ {
if (!PROFILE.cpap->userEventFlagging()) { return; } if (!p_profile->cpap->userEventFlagging()) { return; }
int numbreaths = breaths.size(); int numbreaths = breaths.size();
@ -639,7 +639,7 @@ void FlowParser::flagEvents()
double st, et, dur; //mt double st, et, dur; //mt
qint64 len; qint64 len;
bool allowDuplicates = PROFILE.cpap->userEventDuplicates(); bool allowDuplicates = p_profile->cpap->userEventDuplicates();
BreathPeak *bpstr = breaths.data(); BreathPeak *bpstr = breaths.data();
BreathPeak *bpend = bpstr + numbreaths; BreathPeak *bpend = bpstr + numbreaths;
@ -665,7 +665,7 @@ void FlowParser::flagEvents()
EventDataType peak = br[idx]; //*(br.begin()+idx); EventDataType peak = br[idx]; //*(br.begin()+idx);
EventDataType cutoffval = peak * (PROFILE.cpap->userFlowRestriction() / 100.0F); EventDataType cutoffval = peak * (p_profile->cpap->userFlowRestriction() / 100.0F);
int bs, bm, be, bs1, bm1, be1; int bs, bm, be, bs1, bm1, be1;
@ -738,7 +738,7 @@ void FlowParser::flagEvents()
} }
EventDataType duration = PROFILE.cpap->userEventDuration(); EventDataType duration = p_profile->cpap->userEventDuration();
//double lastst=start, lastet=start; //double lastst=start, lastet=start;
//EventDataType v; //EventDataType v;
int bsize = bstart.size(); int bsize = bstart.size();
@ -860,7 +860,7 @@ void calcRespRate(Session *session, FlowParser *flowparser)
EventDataType calcAHI(Session *session, qint64 start, qint64 end) EventDataType calcAHI(Session *session, qint64 start, qint64 end)
{ {
bool rdi = PROFILE.general->calculateRDI(); bool rdi = p_profile->general->calculateRDI();
double hours, ahi, cnt; double hours, ahi, cnt;
@ -900,7 +900,7 @@ EventDataType calcAHI(Session *session, qint64 start, qint64 end)
int calcAHIGraph(Session *session) int calcAHIGraph(Session *session)
{ {
bool calcrdi = session->machine()->GetClass() == "PRS1"; bool calcrdi = session->machine()->GetClass() == "PRS1";
//PROFILE.general->calculateRDI() //p_profile->general->calculateRDI()
const qint64 window_step = 30000; // 30 second windows const qint64 window_step = 30000; // 30 second windows
@ -1700,10 +1700,10 @@ int calcPulseChange(Session *session)
EventDataType val, val2, change, tmp; EventDataType val, val2, change, tmp;
qint64 time, time2; qint64 time, time2;
qint64 window = PROFILE.oxi->pulseChangeDuration(); qint64 window = p_profile->oxi->pulseChangeDuration();
window *= 1000; window *= 1000;
change = PROFILE.oxi->pulseChangeBPM(); change = p_profile->oxi->pulseChangeBPM();
EventList *pc = new EventList(EVL_Event, 1, 0, 0, 0, 0, true); EventList *pc = new EventList(EVL_Event, 1, 0, 0, 0, 0, true);
pc->setFirst(session->first(OXI_Pulse)); pc->setFirst(session->first(OXI_Pulse));
@ -1779,9 +1779,9 @@ int calcSPO2Drop(Session *session)
EventDataType val, val2, change, tmp; EventDataType val, val2, change, tmp;
qint64 time, time2; qint64 time, time2;
qint64 window = PROFILE.oxi->spO2DropDuration(); qint64 window = p_profile->oxi->spO2DropDuration();
window *= 1000; window *= 1000;
change = PROFILE.oxi->spO2DropPercentage(); change = p_profile->oxi->spO2DropPercentage();
EventList *pc = new EventList(EVL_Event, 1, 0, 0, 0, 0, true); EventList *pc = new EventList(EVL_Event, 1, 0, 0, 0, 0, true);
qint64 lastt; qint64 lastt;

View File

@ -59,7 +59,7 @@ qint64 timezoneOffset()
QString weightString(float kg, UnitSystem us) QString weightString(float kg, UnitSystem us)
{ {
if (us == US_Undefined) { if (us == US_Undefined) {
us = PROFILE.general->unitSystem(); us = p_profile->general->unitSystem();
} }
if (us == US_Metric) { if (us == US_Metric) {

View File

@ -67,11 +67,9 @@ bool CMS50Loader::Detect(const QString &path)
return false; return false;
} }
int CMS50Loader::Open(QString path, Profile *profile) int CMS50Loader::Open(QString path)
{ {
// Only one active Oximeter module at a time, set in preferences // Only one active Oximeter module at a time, set in preferences
Q_UNUSED(profile)
m_itemCnt = 0; m_itemCnt = 0;
m_itemTotal = 0; m_itemTotal = 0;
@ -629,16 +627,14 @@ bool CMS50Loader::readSpoRFile(QString path)
return true; return true;
} }
Machine *CMS50Loader::CreateMachine(Profile *profile) Machine *CMS50Loader::CreateMachine()
{ {
if (!profile) { Q_ASSERT(p_profile != nullptr);
return nullptr;
}
// NOTE: This only allows for one CMS50 machine per profile.. // NOTE: This only allows for one CMS50 machine per profile..
// Upgrading their oximeter will use this same record.. // Upgrading their oximeter will use this same record..
QList<Machine *> ml = profile->GetMachines(MT_OXIMETER); QList<Machine *> ml = p_profile->GetMachines(MT_OXIMETER);
for (QList<Machine *>::iterator i = ml.begin(); i != ml.end(); i++) { for (QList<Machine *>::iterator i = ml.begin(); i != ml.end(); i++) {
if ((*i)->GetClass() == cms50_class_name) { if ((*i)->GetClass() == cms50_class_name) {
@ -649,13 +645,13 @@ Machine *CMS50Loader::CreateMachine(Profile *profile)
qDebug() << "Create CMS50 Machine Record"; qDebug() << "Create CMS50 Machine Record";
Machine *m = new Oximeter(profile, 0); Machine *m = new Oximeter(0);
m->SetClass(cms50_class_name); m->SetClass(cms50_class_name);
m->properties[STR_PROP_Brand] = "Contec"; m->properties[STR_PROP_Brand] = "Contec";
m->properties[STR_PROP_Model] = "CMS50X"; m->properties[STR_PROP_Model] = "CMS50X";
m->properties[STR_PROP_DataVersion] = QString::number(cms50_data_version); m->properties[STR_PROP_DataVersion] = QString::number(cms50_data_version);
profile->AddMachine(m); p_profile->AddMachine(m);
QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + m->hexid() + "/"; QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + m->hexid() + "/";
m->properties[STR_PROP_Path] = path; m->properties[STR_PROP_Path] = path;

View File

@ -31,14 +31,14 @@ Q_OBJECT
virtual ~CMS50Loader(); virtual ~CMS50Loader();
virtual bool Detect(const QString &path); virtual bool Detect(const QString &path);
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
static void Register(); static void Register();
virtual int Version() { return cms50_data_version; } virtual int Version() { return cms50_data_version; }
virtual const QString &ClassName() { return cms50_class_name; } virtual const QString &ClassName() { return cms50_class_name; }
Machine *CreateMachine(Profile *profile); Machine *CreateMachine();
virtual void process(); virtual void process();

View File

@ -22,8 +22,8 @@ extern QProgressBar *qprogress;
const QString FPHCARE = "FPHCARE"; const QString FPHCARE = "FPHCARE";
FPIcon::FPIcon(Profile *p, MachineID id) FPIcon::FPIcon(MachineID id)
: CPAP(p, id) : CPAP(id)
{ {
m_class = fpicon_class_name; m_class = fpicon_class_name;
} }
@ -64,7 +64,7 @@ bool FPIconLoader::Detect(const QString & givenpath)
} }
int FPIconLoader::Open(QString path, Profile *profile) int FPIconLoader::Open(QString path)
{ {
QString newpath; QString newpath;
@ -115,15 +115,15 @@ int FPIconLoader::Open(QString path, Profile *profile)
for (int i = 0; i < SerialNumbers.size(); i++) { for (int i = 0; i < SerialNumbers.size(); i++) {
QString &sn = SerialNumbers[i]; QString &sn = SerialNumbers[i];
m = CreateMachine(sn, profile); m = CreateMachine(sn);
npath = newpath + "/" + sn; npath = newpath + "/" + sn;
try { try {
if (m) { OpenMachine(m, npath, profile); } if (m) { OpenMachine(m, npath); }
} catch (OneTypePerDay e) { } catch (OneTypePerDay e) {
Q_UNUSED(e) Q_UNUSED(e)
profile->DelMachine(m); p_profile->DelMachine(m);
MachList.erase(MachList.find(sn)); MachList.erase(MachList.find(sn));
QMessageBox::warning(nullptr, "Import Error", QMessageBox::warning(nullptr, "Import Error",
"This Machine Record cannot be imported in this profile.\nThe Day records overlap with already existing content.", "This Machine Record cannot be imported in this profile.\nThe Day records overlap with already existing content.",
@ -166,7 +166,7 @@ bool operator<(const FPWaveChunk &a, const FPWaveChunk &b)
return (a.st < b.st); return (a.st < b.st);
} }
int FPIconLoader::OpenMachine(Machine *mach, QString &path, Profile *profile) int FPIconLoader::OpenMachine(Machine *mach, QString &path)
{ {
qDebug() << "Opening FPIcon " << path; qDebug() << "Opening FPIcon " << path;
QDir dir(path); QDir dir(path);
@ -193,7 +193,7 @@ int FPIconLoader::OpenMachine(Machine *mach, QString &path, Profile *profile)
if (filename.left(3).toUpper() == "SUM") { if (filename.left(3).toUpper() == "SUM") {
summary.push_back(fpath); summary.push_back(fpath);
OpenSummary(mach, fpath, profile); OpenSummary(mach, fpath);
} else if (filename.left(3).toUpper() == "DET") { } else if (filename.left(3).toUpper() == "DET") {
det.push_back(fpath); det.push_back(fpath);
} else if (filename.left(3).toUpper() == "FLW") { } else if (filename.left(3).toUpper() == "FLW") {
@ -204,11 +204,11 @@ int FPIconLoader::OpenMachine(Machine *mach, QString &path, Profile *profile)
} }
for (int i = 0; i < det.size(); i++) { for (int i = 0; i < det.size(); i++) {
OpenDetail(mach, det[i], profile); OpenDetail(mach, det[i]);
} }
for (int i = 0; i < flw.size(); i++) { for (int i = 0; i < flw.size(); i++) {
OpenFLW(mach, flw[i], profile); OpenFLW(mach, flw[i]);
} }
SessionID sid;//,st; SessionID sid;//,st;
@ -413,10 +413,9 @@ hour=(ts >> 12) & 0x1f; */
// 0x01ff 8 bit additive sum checksum byte of previous header bytes // 0x01ff 8 bit additive sum checksum byte of previous header bytes
// 0x0200-0x0203 32bit timestamp in // 0x0200-0x0203 32bit timestamp in
bool FPIconLoader::OpenFLW(Machine *mach, QString filename, Profile *profile) bool FPIconLoader::OpenFLW(Machine *mach, QString filename)
{ {
Q_UNUSED(mach); Q_UNUSED(mach);
Q_UNUSED(profile);
quint32 ts; quint32 ts;
double ti; double ti;
@ -588,11 +587,11 @@ bool FPIconLoader::OpenFLW(Machine *mach, QString filename, Profile *profile)
} }
if (newsess) { if (newsess) {
mach->AddSession(sess, profile); mach->AddSession(sess);
} }
if (profile->session->backupCardData()) { if (p_profile->session->backupCardData()) {
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/"; QString backup = p_profile->Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir; QDir dir;
QString newname = QString("FLW%1.FPH").arg(ts); QString newname = QString("FLW%1.FPH").arg(ts);
dir.mkpath(backup); dir.mkpath(backup);
@ -610,7 +609,7 @@ bool FPIconLoader::OpenFLW(Machine *mach, QString filename, Profile *profile)
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
// Open Summary file // Open Summary file
//////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////
bool FPIconLoader::OpenSummary(Machine *mach, QString filename, Profile *profile) bool FPIconLoader::OpenSummary(Machine *mach, QString filename)
{ {
qDebug() << filename; qDebug() << filename;
QByteArray header; QByteArray header;
@ -740,12 +739,12 @@ bool FPIconLoader::OpenSummary(Machine *mach, QString filename, Profile *profile
sess->settings[CPAP_HumidSetting] = x2; sess->settings[CPAP_HumidSetting] = x2;
//sess->settings[CPAP_PresReliefType]=PR_SENSAWAKE; //sess->settings[CPAP_PresReliefType]=PR_SENSAWAKE;
Sessions[ts] = sess; Sessions[ts] = sess;
mach->AddSession(sess, profile); mach->AddSession(sess);
} }
} while (!in.atEnd()); } while (!in.atEnd());
if (profile->session->backupCardData()) { if (p_profile->session->backupCardData()) {
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/"; QString backup = p_profile->Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir; QDir dir;
QString newname = QString("SUM%1.FPH").arg(QDate::currentDate().year(),4,10,QChar('0')); QString newname = QString("SUM%1.FPH").arg(QDate::currentDate().year(),4,10,QChar('0'));
dir.mkpath(backup); dir.mkpath(backup);
@ -758,10 +757,9 @@ bool FPIconLoader::OpenSummary(Machine *mach, QString filename, Profile *profile
return true; return true;
} }
bool FPIconLoader::OpenDetail(Machine *mach, QString filename, Profile *profile) bool FPIconLoader::OpenDetail(Machine *mach, QString filename)
{ {
Q_UNUSED(mach); Q_UNUSED(mach);
Q_UNUSED(profile);
qDebug() << filename; qDebug() << filename;
QByteArray header; QByteArray header;
@ -908,12 +906,12 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename, Profile *profile)
// sess->SetChanged(true); // sess->SetChanged(true);
// mach->AddSession(sess,profile); // mach->AddSession(sess,profile);
} }
if (profile->session->backupCardData()) { if (p_profile->session->backupCardData()) {
unsigned char *data = (unsigned char *)index.data(); unsigned char *data = (unsigned char *)index.data();
ts = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24; ts = data[0] | data[1] << 8 | data[2] << 16 | data[3] << 24;
ts = convertDate(ts); ts = convertDate(ts);
QString backup = PROFILE.Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/"; QString backup = p_profile->Get(mach->properties[STR_PROP_BackupPath])+"FPHCARE/ICON/"+serial.right(serial.size()-4)+"/";
QDir dir; QDir dir;
QString newname = QString("DET%1.FPH").arg(ts); QString newname = QString("DET%1.FPH").arg(ts);
@ -928,15 +926,13 @@ bool FPIconLoader::OpenDetail(Machine *mach, QString filename, Profile *profile)
} }
Machine *FPIconLoader::CreateMachine(QString serial, Profile *profile) Machine *FPIconLoader::CreateMachine(QString serial)
{ {
if (!profile) { Q_ASSERT(p_profile != nullptr);
return nullptr;
}
qDebug() << "Create Machine " << serial; qDebug() << "Create Machine " << serial;
QList<Machine *> ml = profile->GetMachines(MT_CPAP); QList<Machine *> ml = p_profile->GetMachines(MT_CPAP);
bool found = false; bool found = false;
QList<Machine *>::iterator i; QList<Machine *>::iterator i;
Machine *m; Machine *m;
@ -951,7 +947,7 @@ Machine *FPIconLoader::CreateMachine(QString serial, Profile *profile)
} }
if (!found) { if (!found) {
m = new FPIcon(profile, 0); m = new FPIcon(0);
} }
m->properties[STR_PROP_Brand] = "Fisher & Paykel"; m->properties[STR_PROP_Brand] = "Fisher & Paykel";
@ -964,7 +960,7 @@ Machine *FPIconLoader::CreateMachine(QString serial, Profile *profile)
MachList[serial] = m; MachList[serial] = m;
profile->AddMachine(m); p_profile->AddMachine(m);
m->properties[STR_PROP_Serial] = serial; m->properties[STR_PROP_Serial] = serial;
m->properties[STR_PROP_DataVersion] = QString::number(fpicon_data_version); m->properties[STR_PROP_DataVersion] = QString::number(fpicon_data_version);

View File

@ -33,7 +33,7 @@ const int fpicon_data_version = 3;
class FPIcon: public CPAP class FPIcon: public CPAP
{ {
public: public:
FPIcon(Profile *p, MachineID id = 0); FPIcon(MachineID id = 0);
virtual ~FPIcon(); virtual ~FPIcon();
}; };
@ -58,13 +58,13 @@ class FPIconLoader : public MachineLoader
virtual bool Detect(const QString & path); virtual bool Detect(const QString & path);
//! \brief Scans path for F&P Icon data signature, and Loads any new data //! \brief Scans path for F&P Icon data signature, and Loads any new data
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
int OpenMachine(Machine *mach, QString &path, Profile *profile); int OpenMachine(Machine *mach, QString &path);
bool OpenSummary(Machine *mach, QString path, Profile *profile); bool OpenSummary(Machine *mach, QString path);
bool OpenDetail(Machine *mach, QString path, Profile *profile); bool OpenDetail(Machine *mach, QString path);
bool OpenFLW(Machine *mach, QString filename, Profile *profile); bool OpenFLW(Machine *mach, QString filename);
//! \brief Returns SleepLib database version of this F&P Icon loader //! \brief Returns SleepLib database version of this F&P Icon loader
virtual int Version() { return fpicon_data_version; } virtual int Version() { return fpicon_data_version; }
@ -73,7 +73,7 @@ class FPIconLoader : public MachineLoader
virtual const QString &ClassName() { return fpicon_class_name; } virtual const QString &ClassName() { return fpicon_class_name; }
//! \brief Creates a machine object, indexed by serial number //! \brief Creates a machine object, indexed by serial number
Machine *CreateMachine(QString serial, Profile *profile); Machine *CreateMachine(QString serial);
//! \brief Registers this MachineLoader with the master list, so F&P Icon data can load //! \brief Registers this MachineLoader with the master list, so F&P Icon data can load
static void Register(); static void Register();

View File

@ -17,8 +17,8 @@
extern QProgressBar *qprogress; extern QProgressBar *qprogress;
Intellipap::Intellipap(Profile *p, MachineID id) Intellipap::Intellipap(MachineID id)
: CPAP(p, id) : CPAP(id)
{ {
m_class = intellipap_class_name; m_class = intellipap_class_name;
} }
@ -58,7 +58,7 @@ bool IntellipapLoader::Detect(const QString & givenpath)
return true; return true;
} }
int IntellipapLoader::Open(QString path, Profile *profile) int IntellipapLoader::Open(QString path)
{ {
// Check for SL directory // Check for SL directory
// Check for DV5MFirm.bin? // Check for DV5MFirm.bin?
@ -153,7 +153,7 @@ int IntellipapLoader::Open(QString path, Profile *profile)
Machine *mach = nullptr; Machine *mach = nullptr;
if (set1.contains(STR_PROP_Serial)) { if (set1.contains(STR_PROP_Serial)) {
mach = CreateMachine(set1[STR_PROP_Serial], profile); mach = CreateMachine(set1[STR_PROP_Serial]);
} }
if (!mach) { if (!mach) {
@ -410,17 +410,11 @@ int IntellipapLoader::Open(QString path, Profile *profile)
sess->settings[CPAP_RampPressure] = pres; sess->settings[CPAP_RampPressure] = pres;
} }
//quint64 len=last-first;
//if (len>0) {
//if (!sess->first()) {
sess->set_first(first); sess->set_first(first);
sess->set_last(last); sess->set_last(last);
// }
sess->UpdateSummaries(); sess->UpdateSummaries();
mach->AddSession(sess, profile); mach->AddSession(sess);
/*} else {
delete sess;
}*/
} }
} }
@ -437,15 +431,13 @@ int IntellipapLoader::Open(QString path, Profile *profile)
return 1; return 1;
} }
Machine *IntellipapLoader::CreateMachine(QString serial, Profile *profile) Machine *IntellipapLoader::CreateMachine(QString serial)
{ {
if (!profile) { Q_ASSERT(p_profile != nullptr);
return nullptr;
}
qDebug() << "Create Machine " << serial; qDebug() << "Create Machine " << serial;
QList<Machine *> ml = profile->GetMachines(MT_CPAP); QList<Machine *> ml = p_profile->GetMachines(MT_CPAP);
bool found = false; bool found = false;
QList<Machine *>::iterator i; QList<Machine *>::iterator i;
Machine *m = nullptr; Machine *m = nullptr;
@ -460,7 +452,7 @@ Machine *IntellipapLoader::CreateMachine(QString serial, Profile *profile)
} }
if (!found) { if (!found) {
m = new Intellipap(profile, 0); m = new Intellipap(0);
} }
m->properties[STR_PROP_Brand] = "DeVilbiss"; m->properties[STR_PROP_Brand] = "DeVilbiss";
@ -472,7 +464,7 @@ Machine *IntellipapLoader::CreateMachine(QString serial, Profile *profile)
MachList[serial] = m; MachList[serial] = m;
profile->AddMachine(m); p_profile->AddMachine(m);
m->properties[STR_PROP_Serial] = serial; m->properties[STR_PROP_Serial] = serial;
m->properties[STR_PROP_DataVersion] = QString::number(intellipap_data_version); m->properties[STR_PROP_DataVersion] = QString::number(intellipap_data_version);

View File

@ -32,7 +32,7 @@ const int intellipap_data_version = 3;
class Intellipap: public CPAP class Intellipap: public CPAP
{ {
public: public:
Intellipap(Profile *p, MachineID id = 0); Intellipap(MachineID id = 0);
virtual ~Intellipap(); virtual ~Intellipap();
}; };
@ -56,7 +56,7 @@ class IntellipapLoader : public MachineLoader
virtual bool Detect(const QString & path); virtual bool Detect(const QString & path);
//! \brief Scans path for Intellipap data signature, and Loads any new data //! \brief Scans path for Intellipap data signature, and Loads any new data
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
//! \brief Returns SleepLib database version of this IntelliPap loader //! \brief Returns SleepLib database version of this IntelliPap loader
virtual int Version() { return intellipap_data_version; } virtual int Version() { return intellipap_data_version; }
@ -65,7 +65,7 @@ class IntellipapLoader : public MachineLoader
virtual const QString &ClassName() { return intellipap_class_name; } virtual const QString &ClassName() { return intellipap_class_name; }
//! \brief Creates a machine object, indexed by serial number //! \brief Creates a machine object, indexed by serial number
Machine *CreateMachine(QString serial, Profile *profile); Machine *CreateMachine(QString serial);
//! \brief Registers this MachineLoader with the master list, so Intellipap data can load //! \brief Registers this MachineLoader with the master list, so Intellipap data can load
static void Register(); static void Register();

View File

@ -64,11 +64,9 @@ bool MD300W1Loader::Detect(const QString &path)
return false; return false;
} }
int MD300W1Loader::Open(QString path, Profile *profile) int MD300W1Loader::Open(QString path)
{ {
// Only one active Oximeter module at a time, set in preferences // Only one active Oximeter module at a time, set in preferences
Q_UNUSED(profile)
m_itemCnt = 0; m_itemCnt = 0;
m_itemTotal = 0; m_itemTotal = 0;
@ -223,16 +221,14 @@ bool MD300W1Loader::readDATFile(QString path)
return true; return true;
} }
Machine *MD300W1Loader::CreateMachine(Profile *profile) Machine *MD300W1Loader::CreateMachine()
{ {
if (!profile) { Q_ASSERT(p_profile);
return nullptr;
}
// NOTE: This only allows for one MD300W1 machine per profile.. // NOTE: This only allows for one MD300W1 machine per profile..
// Upgrading their oximeter will use this same record.. // Upgrading their oximeter will use this same record..
QList<Machine *> ml = profile->GetMachines(MT_OXIMETER); QList<Machine *> ml = p_profile->GetMachines(MT_OXIMETER);
for (QList<Machine *>::iterator i = ml.begin(); i != ml.end(); i++) { for (QList<Machine *>::iterator i = ml.begin(); i != ml.end(); i++) {
if ((*i)->GetClass() == md300w1_class_name) { if ((*i)->GetClass() == md300w1_class_name) {
@ -243,13 +239,13 @@ Machine *MD300W1Loader::CreateMachine(Profile *profile)
qDebug() << "Create MD300W1 Machine Record"; qDebug() << "Create MD300W1 Machine Record";
Machine *m = new Oximeter(profile, 0); Machine *m = new Oximeter(0);
m->SetClass(md300w1_class_name); m->SetClass(md300w1_class_name);
m->properties[STR_PROP_Brand] = "ChoiceMMed"; m->properties[STR_PROP_Brand] = "ChoiceMMed";
m->properties[STR_PROP_Model] = "MD300W1"; m->properties[STR_PROP_Model] = "MD300W1";
m->properties[STR_PROP_DataVersion] = QString::number(md300w1_data_version); m->properties[STR_PROP_DataVersion] = QString::number(md300w1_data_version);
profile->AddMachine(m); p_profile->AddMachine(m);
QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + m->hexid() + "/"; QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + m->hexid() + "/";
m->properties[STR_PROP_Path] = path; m->properties[STR_PROP_Path] = path;

View File

@ -31,14 +31,14 @@ Q_OBJECT
virtual ~MD300W1Loader(); virtual ~MD300W1Loader();
virtual bool Detect(const QString &path); virtual bool Detect(const QString &path);
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
static void Register(); static void Register();
virtual int Version() { return md300w1_data_version; } virtual int Version() { return md300w1_data_version; }
virtual const QString &ClassName() { return md300w1_class_name; } virtual const QString &ClassName() { return md300w1_class_name; }
Machine *CreateMachine(Profile *profile); Machine *CreateMachine();
virtual void process(); virtual void process();

View File

@ -17,8 +17,8 @@ extern QProgressBar *qprogress;
MSeries::MSeries(Profile *p, MachineID id) MSeries::MSeries(MachineID id)
: CPAP(p, id) : CPAP(id)
{ {
m_class = mseries_class_name; m_class = mseries_class_name;
properties[STR_PROP_Brand] = "Respironics"; properties[STR_PROP_Brand] = "Respironics";
@ -115,9 +115,8 @@ blockLayoutOffsets {
*/ */
int MSeriesLoader::Open(QString path, Profile *profile) int MSeriesLoader::Open(QString path)
{ {
Q_UNUSED(profile);
// Until a smartcard reader is written, this is not an auto-scanner.. it just opens a block file.. // Until a smartcard reader is written, this is not an auto-scanner.. it just opens a block file..
QFile file(path); QFile file(path);
@ -485,15 +484,13 @@ int MSeriesLoader::Open(QString path, Profile *profile)
return 1; return 1;
} }
Machine *MSeriesLoader::CreateMachine(QString serial, Profile *profile) Machine *MSeriesLoader::CreateMachine(QString serial)
{ {
if (!profile) { Q_ASSERT(p_profile != nullptr);
return nullptr;
}
qDebug() << "Create Machine " << serial; qDebug() << "Create Machine " << serial;
QList<Machine *> ml = profile->GetMachines(MT_CPAP); QList<Machine *> ml = p_profile->GetMachines(MT_CPAP);
bool found = false; bool found = false;
QList<Machine *>::iterator i; QList<Machine *>::iterator i;
@ -507,10 +504,10 @@ Machine *MSeriesLoader::CreateMachine(QString serial, Profile *profile)
if (found) { return *i; } if (found) { return *i; }
Machine *m = new MSeries(profile, 0); Machine *m = new MSeries(0);
MachList[serial] = m; MachList[serial] = m;
profile->AddMachine(m); p_profile->AddMachine(m);
m->properties[STR_PROP_Serial] = serial; m->properties[STR_PROP_Serial] = serial;
m->properties[STR_PROP_DataVersion] = QString::number(mseries_data_version); m->properties[STR_PROP_DataVersion] = QString::number(mseries_data_version);

View File

@ -31,7 +31,7 @@ const int mseries_data_version = 2;
class MSeries: public CPAP class MSeries: public CPAP
{ {
public: public:
MSeries(Profile *p, MachineID id = 0); MSeries(MachineID id = 0);
virtual ~MSeries(); virtual ~MSeries();
}; };
@ -51,7 +51,7 @@ class MSeriesLoader : public MachineLoader
virtual bool Detect(const QString & path) { Q_UNUSED(path); return false; } virtual bool Detect(const QString & path) { Q_UNUSED(path); return false; }
//! \brief Opens M-Series block device //! \brief Opens M-Series block device
virtual int Open(QString file, Profile *profile); virtual int Open(QString file);
//! \brief Returns the database version of this loader //! \brief Returns the database version of this loader
virtual int Version() { return mseries_data_version; } virtual int Version() { return mseries_data_version; }
@ -60,7 +60,7 @@ class MSeriesLoader : public MachineLoader
virtual const QString &ClassName() { return mseries_class_name; } virtual const QString &ClassName() { return mseries_class_name; }
//! \brief Create a new PRS1 machine record, indexed by Serial number. //! \brief Create a new PRS1 machine record, indexed by Serial number.
Machine *CreateMachine(QString serial, Profile *profile); Machine *CreateMachine(QString serial);
//! \brief Register this Module to the list of Loaders, so it knows to search for PRS1 data. //! \brief Register this Module to the list of Loaders, so it knows to search for PRS1 data.
static void Register(); static void Register();

View File

@ -99,7 +99,7 @@ crc_t CRC16(const unsigned char *data, size_t data_len)
} }
#endif #endif
PRS1::PRS1(Profile *p, MachineID id): CPAP(p, id) PRS1::PRS1(MachineID id): CPAP(id)
{ {
m_class = prs1_class_name; m_class = prs1_class_name;
} }
@ -130,15 +130,13 @@ PRS1Loader::PRS1Loader()
PRS1Loader::~PRS1Loader() PRS1Loader::~PRS1Loader()
{ {
} }
Machine *PRS1Loader::CreateMachine(QString serial, Profile *profile) Machine *PRS1Loader::CreateMachine(QString serial)
{ {
if (!profile) { Q_ASSERT(p_profile != nullptr);
return nullptr;
}
qDebug() << "Create Machine " << serial; qDebug() << "Create Machine " << serial;
QList<Machine *> ml = profile->GetMachines(MT_CPAP); QList<Machine *> ml = p_profile->GetMachines(MT_CPAP);
bool found = false; bool found = false;
QList<Machine *>::iterator i; QList<Machine *>::iterator i;
Machine *m = nullptr; Machine *m = nullptr;
@ -153,7 +151,7 @@ Machine *PRS1Loader::CreateMachine(QString serial, Profile *profile)
} }
if (!found) { if (!found) {
m = new PRS1(profile, 0); m = new PRS1(0);
} }
m->properties[STR_PROP_Brand] = "Philips Respironics"; m->properties[STR_PROP_Brand] = "Philips Respironics";
@ -164,7 +162,7 @@ Machine *PRS1Loader::CreateMachine(QString serial, Profile *profile)
} }
PRS1List[serial] = m; PRS1List[serial] = m;
profile->AddMachine(m); p_profile->AddMachine(m);
m->properties[STR_PROP_Serial] = serial; m->properties[STR_PROP_Serial] = serial;
m->properties[STR_PROP_DataVersion] = QString::number(prs1_data_version); m->properties[STR_PROP_DataVersion] = QString::number(prs1_data_version);
@ -226,7 +224,7 @@ bool PRS1Loader::Detect(const QString & path)
return true; return true;
} }
int PRS1Loader::Open(QString path, Profile *profile) int PRS1Loader::Open(QString path)
{ {
QString newpath; QString newpath;
path = path.replace("\\", "/"); path = path.replace("\\", "/");
@ -285,15 +283,15 @@ int PRS1Loader::Open(QString path, Profile *profile)
for (sn = SerialNumbers.begin(); sn != SerialNumbers.end(); sn++) { for (sn = SerialNumbers.begin(); sn != SerialNumbers.end(); sn++) {
QString s = *sn; QString s = *sn;
m = CreateMachine(s, profile); m = CreateMachine(s);
try { try {
if (m) { if (m) {
OpenMachine(m, newpath + "/" + (*sn), profile); OpenMachine(m, newpath + "/" + (*sn));
} }
} catch (OneTypePerDay e) { } catch (OneTypePerDay e) {
Q_UNUSED(e) Q_UNUSED(e)
profile->DelMachine(m); p_profile->DelMachine(m);
PRS1List.erase(PRS1List.find(s)); PRS1List.erase(PRS1List.find(s));
QMessageBox::warning(nullptr, QObject::tr("Import Error"), QMessageBox::warning(nullptr, QObject::tr("Import Error"),
QObject::tr("This Machine Record cannot be imported in this profile.\nThe Day records overlap with already existing content."), QObject::tr("This Machine Record cannot be imported in this profile.\nThe Day records overlap with already existing content."),
@ -381,9 +379,9 @@ void copyPath(QString src, QString dst)
} }
int PRS1Loader::OpenMachine(Machine *m, QString path, Profile *profile) int PRS1Loader::OpenMachine(Machine *m, QString path)
{ {
Q_UNUSED(profile) Q_ASSERT(p_profile != nullptr);
qDebug() << "Opening PRS1 " << path; qDebug() << "Opening PRS1 " << path;
QDir dir(path); QDir dir(path);
@ -1489,7 +1487,7 @@ void PRS1Import::run()
sg->session->SetChanged(true); sg->session->SetChanged(true);
loader->sessionMutex.lock(); loader->sessionMutex.lock();
mach->AddSession(sg->session, p_profile); mach->AddSession(sg->session);
loader->sessionMutex.unlock(); loader->sessionMutex.unlock();
// Update indexes, process waveform and perform flagging // Update indexes, process waveform and perform flagging

View File

@ -33,7 +33,7 @@ const int prs1_data_version = 13;
class PRS1: public CPAP class PRS1: public CPAP
{ {
public: public:
PRS1(Profile *p, MachineID id = 0); PRS1(MachineID id = 0);
virtual ~PRS1(); virtual ~PRS1();
}; };
@ -184,7 +184,7 @@ class PRS1Loader : public MachineLoader
virtual bool Detect(const QString & path); virtual bool Detect(const QString & path);
//! \brief Scans directory path for valid PRS1 signature //! \brief Scans directory path for valid PRS1 signature
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
//! \brief Returns the database version of this loader //! \brief Returns the database version of this loader
virtual int Version() { return prs1_data_version; } virtual int Version() { return prs1_data_version; }
@ -193,7 +193,7 @@ class PRS1Loader : public MachineLoader
virtual const QString &ClassName() { return prs1_class_name; } virtual const QString &ClassName() { return prs1_class_name; }
//! \brief Create a new PRS1 machine record, indexed by Serial number. //! \brief Create a new PRS1 machine record, indexed by Serial number.
Machine *CreateMachine(QString serial, Profile *profile); Machine *CreateMachine(QString serial);
//! \brief Register this Module to the list of Loaders, so it knows to search for PRS1 data. //! \brief Register this Module to the list of Loaders, so it knows to search for PRS1 data.
static void Register(); static void Register();
@ -205,7 +205,7 @@ class PRS1Loader : public MachineLoader
QHash<QString, Machine *> PRS1List; QHash<QString, Machine *> PRS1List;
//! \brief Opens the SD folder structure for this machine, scans for data files and imports any new sessions //! \brief Opens the SD folder structure for this machine, scans for data files and imports any new sessions
int OpenMachine(Machine *m, QString path, Profile *profile); int OpenMachine(Machine *m, QString path);
//! \brief Parses "properties.txt" file containing machine information //! \brief Parses "properties.txt" file containing machine information
bool ParseProperties(Machine *m, QString filename); bool ParseProperties(Machine *m, QString filename);

View File

@ -695,7 +695,7 @@ void ResmedImport::run()
if (sess->length() > 0) { if (sess->length() > 0) {
loader->saveMutex.lock(); loader->saveMutex.lock();
if (!mach->AddSession(sess, p_profile)) { if (!mach->AddSession(sess)) {
delete sess; delete sess;
loader->saveMutex.unlock(); loader->saveMutex.unlock();
return; return;
@ -727,18 +727,18 @@ ResmedLoader::~ResmedLoader()
{ {
} }
Machine *ResmedLoader::CreateMachine(QString serial, Profile *profile) Machine *ResmedLoader::CreateMachine(QString serial)
{ {
if (!profile) { return nullptr; } Q_ASSERT(p_profile != nullptr);
QList<Machine *> ml = profile->GetMachines(MT_CPAP); QList<Machine *> ml = p_profile->GetMachines(MT_CPAP);
bool found = false; bool found = false;
QList<Machine *>::iterator i; QList<Machine *>::iterator i;
Machine *m = nullptr; Machine *m = nullptr;
for (i = ml.begin(); i != ml.end(); i++) { for (i = ml.begin(); i != ml.end(); i++) {
if (((*i)->GetClass() == resmed_class_name) && ((*i)->properties[STR_PROP_Serial] == serial)) { if (((*i)->GetClass() == resmed_class_name) && ((*i)->properties[STR_PROP_Serial] == serial)) {
ResmedList[serial] = *i; //static_cast<CPAP *>(*i); ResmedList[serial] = *i;
found = true; found = true;
m = *i; m = *i;
break; break;
@ -746,7 +746,7 @@ Machine *ResmedLoader::CreateMachine(QString serial, Profile *profile)
} }
if (!found) { if (!found) {
m = new CPAP(profile, 0); m = new CPAP(0);
} }
m->properties[STR_PROP_Brand] = STR_MACH_ResMed; m->properties[STR_PROP_Brand] = STR_MACH_ResMed;
@ -760,7 +760,7 @@ Machine *ResmedLoader::CreateMachine(QString serial, Profile *profile)
m->SetClass(resmed_class_name); m->SetClass(resmed_class_name);
ResmedList[serial] = m; ResmedList[serial] = m;
profile->AddMachine(m); p_profile->AddMachine(m);
m->properties[STR_PROP_Serial] = serial; m->properties[STR_PROP_Serial] = serial;
m->properties[STR_PROP_DataVersion] = QString::number(resmed_data_version); m->properties[STR_PROP_DataVersion] = QString::number(resmed_data_version);
@ -871,7 +871,7 @@ void ResmedImportStage2::run()
} }
loader->saveMutex.lock(); loader->saveMutex.lock();
mach->AddSession(sess, p_profile); mach->AddSession(sess);
sess->Store(p_profile->Get(mach->properties[STR_PROP_Path])); sess->Store(p_profile->Get(mach->properties[STR_PROP_Path]));
loader->saveMutex.unlock(); loader->saveMutex.unlock();
} }
@ -904,7 +904,7 @@ bool ResmedLoader::Detect(const QString & givenpath)
return true; return true;
} }
int ResmedLoader::Open(QString path, Profile *profile) int ResmedLoader::Open(QString path)
{ {
QString serial; // Serial number QString serial; // Serial number
@ -998,15 +998,15 @@ int ResmedLoader::Open(QString path, Profile *profile)
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
// Create machine object (unless it's already registered) // Create machine object (unless it's already registered)
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
Machine *m = CreateMachine(serial, profile); Machine *m = CreateMachine(serial);
bool create_backups = PROFILE.session->backupCardData(); bool create_backups = p_profile->session->backupCardData();
bool compress_backups = PROFILE.session->compressBackupData(); bool compress_backups = p_profile->session->compressBackupData();
QString backup_path = PROFILE.Get(m->properties[STR_PROP_BackupPath]); QString backup_path = p_profile->Get(m->properties[STR_PROP_BackupPath]);
if (backup_path.isEmpty()) { if (backup_path.isEmpty()) {
backup_path = PROFILE.Get(m->properties[STR_PROP_Path]) + "Backup/"; backup_path = p_profile->Get(m->properties[STR_PROP_Path]) + "Backup/";
} }
if (path == backup_path) { if (path == backup_path) {
@ -1340,9 +1340,9 @@ int ResmedLoader::Open(QString path, Profile *profile)
size = strsess.size(); size = strsess.size();
cnt=0; cnt=0;
quint32 ignoreolder = PROFILE.session->ignoreOlderSessionsDate().toTime_t(); quint32 ignoreolder = p_profile->session->ignoreOlderSessionsDate().toTime_t();
bool ignoreold = PROFILE.session->ignoreOlderSessions(); bool ignoreold = p_profile->session->ignoreOlderSessions();
// strsess end can change above. // strsess end can change above.
end = strsess.end(); end = strsess.end();

View File

@ -340,7 +340,7 @@ class ResmedLoader : public MachineLoader
virtual bool Detect(const QString & path); virtual bool Detect(const QString & path);
//! \brief Scans for S9 SD folder structure signature, and loads any new data if found //! \brief Scans for S9 SD folder structure signature, and loads any new data if found
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
//! \brief Returns the version number of this ResMed loader //! \brief Returns the version number of this ResMed loader
virtual int Version() { return resmed_data_version; } virtual int Version() { return resmed_data_version; }
@ -353,7 +353,7 @@ class ResmedLoader : public MachineLoader
qint64 duration, EventDataType min = 0, EventDataType max = 0, bool square = false); qint64 duration, EventDataType min = 0, EventDataType max = 0, bool square = false);
//! \brief Create Machine record, and index it by serial number //! \brief Create Machine record, and index it by serial number
Machine *CreateMachine(QString serial, Profile *profile); Machine *CreateMachine(QString serial);
//! \brief Register the ResmedLoader with the list of other machine loaders //! \brief Register the ResmedLoader with the list of other machine loaders
static void Register(); static void Register();

View File

@ -29,10 +29,9 @@ SomnoposeLoader::SomnoposeLoader()
SomnoposeLoader::~SomnoposeLoader() SomnoposeLoader::~SomnoposeLoader()
{ {
} }
int SomnoposeLoader::Open(QString path, Profile *profile) int SomnoposeLoader::Open(QString path)
{ {
Q_UNUSED(path) Q_UNUSED(path)
Q_UNUSED(profile)
QString newpath; QString newpath;
@ -55,13 +54,11 @@ int SomnoposeLoader::Open(QString path, Profile *profile)
return 0; // number of machines affected return 0; // number of machines affected
} }
Machine *SomnoposeLoader::CreateMachine(Profile *profile) Machine *SomnoposeLoader::CreateMachine()
{ {
if (!profile) { Q_ASSERT(p_profile != nullptr);
return nullptr;
}
QList<Machine *> ml = profile->GetMachines(MT_POSITION); QList<Machine *> ml = p_profile->GetMachines(MT_POSITION);
for (QList<Machine *>::iterator i = ml.begin(); i != ml.end(); i++) { for (QList<Machine *>::iterator i = ml.begin(); i != ml.end(); i++) {
if ((*i)->GetClass() == somnopose_class_name) { if ((*i)->GetClass() == somnopose_class_name) {
@ -72,14 +69,14 @@ Machine *SomnoposeLoader::CreateMachine(Profile *profile)
qDebug("Create Somnopose Machine Record"); qDebug("Create Somnopose Machine Record");
Machine *m = new PositionSensor(profile, 0); Machine *m = new PositionSensor(0);
m->SetType(MT_POSITION); m->SetType(MT_POSITION);
m->SetClass(somnopose_class_name); m->SetClass(somnopose_class_name);
m->properties[STR_PROP_Brand] = "Somnopose"; m->properties[STR_PROP_Brand] = "Somnopose";
m->properties[STR_PROP_Model] = "Somnopose Position Data"; m->properties[STR_PROP_Model] = "Somnopose Position Data";
m->properties[STR_PROP_DataVersion] = QString::number(somnopose_data_version); m->properties[STR_PROP_DataVersion] = QString::number(somnopose_data_version);
profile->AddMachine(m); p_profile->AddMachine(m);
QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + m->hexid() + "/"; QString path = "{" + STR_GEN_DataFolder + "}/" + m->GetClass() + "_" + m->hexid() + "/";
m->properties[STR_PROP_Path] = path; m->properties[STR_PROP_Path] = path;
@ -140,7 +137,7 @@ int SomnoposeLoader::OpenFile(QString filename)
bool ok; bool ok;
bool first = true; bool first = true;
Machine *mach = CreateMachine(p_profile); Machine *mach = CreateMachine();
Session *sess = nullptr; Session *sess = nullptr;
SessionID sid; SessionID sid;
@ -197,7 +194,7 @@ int SomnoposeLoader::OpenFile(QString filename)
sess->really_set_last(time); sess->really_set_last(time);
sess->SetChanged(true); sess->SetChanged(true);
mach->AddSession(sess, p_profile); mach->AddSession(sess);
mach->Save(); mach->Save();

View File

@ -28,7 +28,7 @@ class SomnoposeLoader : public MachineLoader
virtual ~SomnoposeLoader(); virtual ~SomnoposeLoader();
virtual bool Detect(const QString &path) { Q_UNUSED(path); return false; } // bypass autoscanner virtual bool Detect(const QString &path) { Q_UNUSED(path); return false; } // bypass autoscanner
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
virtual int OpenFile(QString filename); virtual int OpenFile(QString filename);
static void Register(); static void Register();
@ -36,7 +36,7 @@ class SomnoposeLoader : public MachineLoader
virtual const QString &ClassName() { return somnopose_class_name; } virtual const QString &ClassName() { return somnopose_class_name; }
Machine *CreateMachine(Profile *profile); Machine *CreateMachine();
protected: protected:
private: private:

View File

@ -30,10 +30,9 @@ ZEOLoader::~ZEOLoader()
{ {
} }
int ZEOLoader::Open(QString path, Profile *profile) int ZEOLoader::Open(QString path)
{ {
Q_UNUSED(path) Q_UNUSED(path)
Q_UNUSED(profile)
QString newpath; QString newpath;
@ -77,7 +76,7 @@ Machine *ZEOLoader::CreateMachine(Profile *profile)
qDebug("Create ZEO Machine Record"); qDebug("Create ZEO Machine Record");
Machine *m = new SleepStage(profile, 0); Machine *m = new SleepStage(0);
m->SetType(MT_SLEEPSTAGE); m->SetType(MT_SLEEPSTAGE);
m->SetClass(zeo_class_name); m->SetClass(zeo_class_name);
m->properties[STR_PROP_Brand] = "ZEO"; m->properties[STR_PROP_Brand] = "ZEO";
@ -344,7 +343,7 @@ int ZEOLoader::OpenFile(QString filename)
sess->really_set_last(tt); sess->really_set_last(tt);
int size = DSG.size(); int size = DSG.size();
sess->SetChanged(true); sess->SetChanged(true);
mach->AddSession(sess, p_profile); mach->AddSession(sess);
qDebug() << linecomp[0] << start_of_night << end_of_night << rise_time << size << qDebug() << linecomp[0] << start_of_night << end_of_night << rise_time << size <<

View File

@ -28,7 +28,7 @@ class ZEOLoader : public MachineLoader
virtual ~ZEOLoader(); virtual ~ZEOLoader();
virtual bool Detect(const QString &path) { Q_UNUSED(path); return false; } // bypass autoscanner virtual bool Detect(const QString &path) { Q_UNUSED(path); return false; } // bypass autoscanner
virtual int Open(QString path, Profile *profile); virtual int Open(QString path);
virtual int OpenFile(QString filename); virtual int OpenFile(QString filename);
static void Register(); static void Register();

View File

@ -29,11 +29,10 @@ extern QProgressBar *qprogress;
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Machine Base-Class implmementation // Machine Base-Class implmementation
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
Machine::Machine(Profile *p, MachineID id) Machine::Machine(MachineID id)
{ {
day.clear(); day.clear();
highest_sessionid = 0; highest_sessionid = 0;
profile = p;
if (!id) { if (!id) {
srand(time(nullptr)); srand(time(nullptr));
@ -41,7 +40,7 @@ Machine::Machine(Profile *p, MachineID id)
do { do {
temp = rand(); temp = rand();
} while (profile->machlist.find(temp) != profile->machlist.end()); } while (p_profile->machlist.find(temp) != p_profile->machlist.end());
m_id = temp; m_id = temp;
@ -71,8 +70,8 @@ Session *Machine::SessionExists(SessionID session)
// Find date this session belongs in // Find date this session belongs in
QDate Machine::pickDate(qint64 first) QDate Machine::pickDate(qint64 first)
{ {
QTime split_time = PROFILE.session->daySplitTime(); QTime split_time = p_profile->session->daySplitTime();
int combine_sessions = PROFILE.session->combineCloseSessions(); int combine_sessions = p_profile->session->combineCloseSessions();
QDateTime d2 = QDateTime::fromTime_t(first / 1000); QDateTime d2 = QDateTime::fromTime_t(first / 1000);
@ -99,13 +98,12 @@ QDate Machine::pickDate(qint64 first)
return date; return date;
} }
bool Machine::AddSession(Session *s, Profile *p) bool Machine::AddSession(Session *s)
{ {
Q_ASSERT(s != nullptr); Q_ASSERT(s != nullptr);
Q_ASSERT(p != nullptr);
if (profile->session->ignoreOlderSessions()) { if (p_profile->session->ignoreOlderSessions()) {
qint64 ignorebefore = profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch(); qint64 ignorebefore = p_profile->session->ignoreOlderSessionsDate().toMSecsSinceEpoch();
if (s->last() < ignorebefore) { if (s->last() < ignorebefore) {
skipped_sessions++; skipped_sessions++;
return false; return false;
@ -116,9 +114,9 @@ bool Machine::AddSession(Session *s, Profile *p)
highest_sessionid = s->session(); highest_sessionid = s->session();
} }
QTime split_time = PROFILE.session->daySplitTime(); QTime split_time = p_profile->session->daySplitTime();
int combine_sessions = PROFILE.session->combineCloseSessions(); int combine_sessions = p_profile->session->combineCloseSessions();
int ignore_sessions = PROFILE.session->ignoreShortSessions(); int ignore_sessions = p_profile->session->ignoreShortSessions();
// ResMed machines can't do this.. but don't really want to do a slow string compare here // ResMed machines can't do this.. but don't really want to do a slow string compare here
@ -127,7 +125,7 @@ bool Machine::AddSession(Session *s, Profile *p)
sessionlist[s->session()] = s; // To make sure it get's saved later even if it's not wanted. sessionlist[s->session()] = s; // To make sure it get's saved later even if it's not wanted.
//int drift=PROFILE.cpap->clockDrift(); //int drift=p_profile->cpap->clockDrift();
QDateTime d2 = QDateTime::fromTime_t(s->first() / 1000); QDateTime d2 = QDateTime::fromTime_t(s->first() / 1000);
@ -190,7 +188,7 @@ bool Machine::AddSession(Session *s, Profile *p)
dd = new Day(this); dd = new Day(this);
day[date] = dd; day[date] = dd;
// Add this Day record to profile // Add this Day record to profile
p->AddDay(date, dd, m_type); p_profile->AddDay(date, dd, m_type);
} else { } else {
dd = *dit; dd = *dit;
} }
@ -202,7 +200,7 @@ bool Machine::AddSession(Session *s, Profile *p)
dd->AddSession(*i); dd->AddSession(*i);
} }
QMap<QDate, QList<Day *> >::iterator nd = p->daylist.find(date.addDays(1)); QMap<QDate, QList<Day *> >::iterator nd = p_profile->daylist.find(date.addDays(1));
for (QList<Day *>::iterator i = nd->begin(); i != nd->end(); i++) { for (QList<Day *>::iterator i = nd->begin(); i != nd->end(); i++) {
if (*i == nextday.value()) { if (*i == nextday.value()) {
@ -222,7 +220,7 @@ bool Machine::Purge(int secret)
// Boring api key to stop this function getting called by accident :) // Boring api key to stop this function getting called by accident :)
if (secret != 3478216) { return false; } if (secret != 3478216) { return false; }
QString path = profile->Get(properties[STR_PROP_Path]); QString path = p_profile->Get(properties[STR_PROP_Path]);
QDir dir(path); QDir dir(path);
@ -296,8 +294,7 @@ bool Machine::Purge(int secret)
bool Machine::Load() bool Machine::Load()
{ {
QString path = profile->Get( QString path = p_profile->Get(properties[STR_PROP_Path]);
properties[STR_PROP_Path]); //STR_GEN_DataFolder)+"/"+m_class+"_"+hexid();
QDir dir(path); QDir dir(path);
qDebug() << "Loading " << QDir::toNativeSeparators(path); qDebug() << "Loading " << QDir::toNativeSeparators(path);
@ -352,8 +349,8 @@ bool Machine::Load()
if (sess->LoadSummary(s.value()[0])) { if (sess->LoadSummary(s.value()[0])) {
sess->SetEventFile(s.value()[1]); sess->SetEventFile(s.value()[1]);
//sess->OpenEvents();
AddSession(sess, profile); AddSession(sess);
} else { } else {
qWarning() << "Error unpacking summary data"; qWarning() << "Error unpacking summary data";
delete sess; delete sess;
@ -364,10 +361,10 @@ bool Machine::Load()
return true; return true;
} }
bool Machine::SaveSession(Session *sess) bool Machine::SaveSession(Session *sess)
{ {
QString path = profile->Get( QString path = p_profile->Get(properties[STR_PROP_Path]);
properties[STR_PROP_Path]); //STR_GEN_DataFolder)+"/"+m_class+"_"+hexid();
if (sess->IsChanged()) { sess->Store(path); } if (sess->IsChanged()) { sess->Store(path); }
@ -383,9 +380,9 @@ void Machine::queSaveList(Session * sess)
QApplication::processEvents(); QApplication::processEvents();
sess->UpdateSummaries(); sess->UpdateSummaries();
sess->Store(profile->Get(properties[STR_PROP_Path])); sess->Store(p_profile->Get(properties[STR_PROP_Path]));
if (!PROFILE.session->cacheSessions()) { if (!p_profile->session->cacheSessions()) {
sess->TrashEvents(); sess->TrashEvents();
} }
@ -417,7 +414,7 @@ void Machine::StartSaveThreads()
m_savelist.clear(); m_savelist.clear();
if (!p_profile->session->multithreading()) return; if (!p_profile->session->multithreading()) return;
QString path = profile->Get(properties[STR_PROP_Path]); QString path = p_profile->Get(properties[STR_PROP_Path]);
int threads = QThread::idealThreadCount(); int threads = QThread::idealThreadCount();
savelistSem = new QSemaphore(threads); savelistSem = new QSemaphore(threads);
@ -517,7 +514,7 @@ void SaveTask::run()
void Machine::queTask(ImportTask * task) void Machine::queTask(ImportTask * task)
{ {
if (0) { //PROFILE.session->multithreading()) { if (0) { //p_profile->session->multithreading()) {
m_tasklist.push_back(task); m_tasklist.push_back(task);
return; return;
} }
@ -528,7 +525,7 @@ void Machine::queTask(ImportTask * task)
void Machine::runTasks() void Machine::runTasks()
{ {
if (0) { //!PROFILE.session->multithreading()) { if (0) { //!p_profile->session->multithreading()) {
Q_ASSERT(m_tasklist.isEmpty()); Q_ASSERT(m_tasklist.isEmpty());
return; return;
} }
@ -552,7 +549,7 @@ bool Machine::Save()
//int size; //int size;
int cnt = 0; int cnt = 0;
QString path = profile->Get(properties[STR_PROP_Path]); QString path = p_profile->Get(properties[STR_PROP_Path]);
QDir dir(path); QDir dir(path);
if (!dir.exists()) { if (!dir.exists()) {
@ -578,7 +575,7 @@ bool Machine::Save()
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// CPAP implmementation // CPAP implmementation
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
CPAP::CPAP(Profile *p, MachineID id): Machine(p, id) CPAP::CPAP(MachineID id): Machine(id)
{ {
m_type = MT_CPAP; m_type = MT_CPAP;
} }
@ -590,7 +587,7 @@ CPAP::~CPAP()
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// Oximeter Class implmementation // Oximeter Class implmementation
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
Oximeter::Oximeter(Profile *p, MachineID id): Machine(p, id) Oximeter::Oximeter(MachineID id): Machine(id)
{ {
m_type = MT_OXIMETER; m_type = MT_OXIMETER;
} }
@ -602,7 +599,7 @@ Oximeter::~Oximeter()
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// SleepStage Class implmementation // SleepStage Class implmementation
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
SleepStage::SleepStage(Profile *p, MachineID id): Machine(p, id) SleepStage::SleepStage(MachineID id): Machine(id)
{ {
m_type = MT_SLEEPSTAGE; m_type = MT_SLEEPSTAGE;
} }
@ -613,7 +610,7 @@ SleepStage::~SleepStage()
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
// PositionSensor Class implmementation // PositionSensor Class implmementation
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
PositionSensor::PositionSensor(Profile *p, MachineID id): Machine(p, id) PositionSensor::PositionSensor(MachineID id): Machine(id)
{ {
m_type = MT_POSITION; m_type = MT_POSITION;
} }

View File

@ -77,12 +77,12 @@ class Machine
friend class SaveThread; friend class SaveThread;
public: public:
/*! \fn Machine(Profile *p,MachineID id=0); /*! \fn Machine(MachineID id=0);
\brief Constructs a Machine object in Profile p, and with MachineID id \brief Constructs a Machine object with MachineID id
If supplied MachineID is zero, it will generate a new unused random one. If supplied MachineID is zero, it will generate a new unused random one.
*/ */
Machine(Profile *p, MachineID id = 0); Machine(MachineID id = 0);
virtual ~Machine(); virtual ~Machine();
//! \brief Load all Machine summary data //! \brief Load all Machine summary data
@ -109,7 +109,7 @@ class Machine
Session *SessionExists(SessionID session); Session *SessionExists(SessionID session);
//! \brief Adds the session to this machine object, and the Master Profile list. (used during load) //! \brief Adds the session to this machine object, and the Master Profile list. (used during load)
bool AddSession(Session *s, Profile *p); bool AddSession(Session *s);
//! \brief Find the date this session belongs in, according to profile settings //! \brief Find the date this session belongs in, according to profile settings
QDate pickDate(qint64 start); QDate pickDate(qint64 start);
@ -187,7 +187,7 @@ class Machine
QString m_class; QString m_class;
MachineType m_type; MachineType m_type;
QString m_path; QString m_path;
Profile *profile;
bool changed; bool changed;
bool firstsession; bool firstsession;
int m_totaltasks; int m_totaltasks;
@ -207,7 +207,7 @@ class Machine
class CPAP: public Machine class CPAP: public Machine
{ {
public: public:
CPAP(Profile *p, MachineID id = 0); CPAP(MachineID id = 0);
virtual ~CPAP(); virtual ~CPAP();
}; };
@ -218,7 +218,7 @@ class CPAP: public Machine
class Oximeter: public Machine class Oximeter: public Machine
{ {
public: public:
Oximeter(Profile *p, MachineID id = 0); Oximeter(MachineID id = 0);
virtual ~Oximeter(); virtual ~Oximeter();
protected: protected:
}; };
@ -229,7 +229,7 @@ class Oximeter: public Machine
class SleepStage: public Machine class SleepStage: public Machine
{ {
public: public:
SleepStage(Profile *p, MachineID id = 0); SleepStage(MachineID id = 0);
virtual ~SleepStage(); virtual ~SleepStage();
protected: protected:
}; };
@ -240,7 +240,7 @@ class SleepStage: public Machine
class PositionSensor: public Machine class PositionSensor: public Machine
{ {
public: public:
PositionSensor(Profile *p, MachineID id = 0); PositionSensor(MachineID id = 0);
virtual ~PositionSensor(); virtual ~PositionSensor();
protected: protected:
}; };

View File

@ -40,7 +40,7 @@ class MachineLoader: public QObject
virtual bool Detect(const QString & path) = 0; virtual bool Detect(const QString & path) = 0;
//! \brief Override this to scan path and detect new machine data //! \brief Override this to scan path and detect new machine data
virtual int Open(QString path, Profile *) = 0; // Scans for new content virtual int Open(QString path) = 0;
//! \brief Override to returns the Version number of this MachineLoader //! \brief Override to returns the Version number of this MachineLoader
virtual int Version() = 0; virtual int Version() = 0;

View File

@ -324,7 +324,7 @@ void Profile::DataFormatError(Machine *m)
,QMessageBox::Ok, QMessageBox::Ok); ,QMessageBox::Ok, QMessageBox::Ok);
mainwin->startImportDialog(); mainwin->startImportDialog();
} }
PROFILE.Save(); p_profile->Save();
delete question; delete question;
} else { } else {
@ -420,15 +420,15 @@ void Profile::ExtraLoad(QDomElement &root)
// ml->CreateMachine // ml->CreateMachine
//} //}
if (m_type == MT_CPAP) { if (m_type == MT_CPAP) {
m = new CPAP(this, m_id); m = new CPAP(m_id);
} else if (m_type == MT_OXIMETER) { } else if (m_type == MT_OXIMETER) {
m = new Oximeter(this, m_id); m = new Oximeter(m_id);
} else if (m_type == MT_SLEEPSTAGE) { } else if (m_type == MT_SLEEPSTAGE) {
m = new SleepStage(this, m_id); m = new SleepStage(m_id);
} else if (m_type == MT_POSITION) { } else if (m_type == MT_POSITION) {
m = new PositionSensor(this, m_id); m = new PositionSensor(m_id);
} else { } else {
m = new Machine(this, m_id); m = new Machine(m_id);
m->SetType(m_type); m->SetType(m_type);
} }
@ -593,7 +593,7 @@ int Profile::Import(QString path)
QList<MachineLoader *>loaders = GetLoaders(MT_CPAP); QList<MachineLoader *>loaders = GetLoaders(MT_CPAP);
Q_FOREACH(MachineLoader * loader, loaders) { Q_FOREACH(MachineLoader * loader, loaders) {
if (c += loader->Open(path, this)) { if (c += loader->Open(path)) {
break; break;
} }
} }
@ -748,7 +748,7 @@ Profile *Create(QString name)
prof->Set(STR_GEN_DataFolder, QString("{home}/Profiles/{") + QString(STR_UI_UserName) + prof->Set(STR_GEN_DataFolder, QString("{home}/Profiles/{") + QString(STR_UI_UserName) +
QString("}")); QString("}"));
Machine *m = new Machine(prof, 0); Machine *m = new Machine(0);
m->SetClass("Journal"); m->SetClass("Journal");
m->properties[STR_PROP_Brand] = "Journal"; m->properties[STR_PROP_Brand] = "Journal";
m->properties[STR_PROP_Model] = "Journal Data Machine Object"; m->properties[STR_PROP_Model] = "Journal Data Machine Object";

View File

@ -215,7 +215,6 @@ extern Profile *p_profile;
// these are bad and must change // these are bad and must change
#define PREF (*p_pref) #define PREF (*p_pref)
#define LAYOUT (*p_layout) #define LAYOUT (*p_layout)
#define PROFILE (*p_profile)
// DoctorInfo Strings // DoctorInfo Strings
const QString STR_DI_Name = "DoctorName"; const QString STR_DI_Name = "DoctorName";

View File

@ -41,7 +41,7 @@ public:
virtual ~SerialOximeter() {} virtual ~SerialOximeter() {}
virtual bool Detect(const QString &path)=0; virtual bool Detect(const QString &path)=0;
virtual int Open(QString path, Profile *profile)=0; virtual int Open(QString path)=0;
static void Register() {} static void Register() {}
@ -60,7 +60,7 @@ public:
virtual void process() {} virtual void process() {}
virtual Machine *CreateMachine(Profile *profile)=0; virtual Machine *CreateMachine()=0;
// available sessions // available sessions
QMap<QDateTime, QVector<OxiRecord> *> oxisessions; QMap<QDateTime, QVector<OxiRecord> *> oxisessions;

View File

@ -112,9 +112,9 @@ bool Session::OpenEvents()
bool Session::Destroy() bool Session::Destroy()
{ {
QString path = PROFILE.Get(s_machine->properties[STR_PROP_Path]); QString path = p_profile->Get(s_machine->properties[STR_PROP_Path]);
PROFILE.RemoveSession(this); p_profile->RemoveSession(this);
s_machine->sessionlist.erase(s_machine->sessionlist.find(s_session)); s_machine->sessionlist.erase(s_machine->sessionlist.find(s_session));
QDir dir(path); QDir dir(path);
@ -1144,7 +1144,7 @@ EventDataType Session::physMax(ChannelID id)
qint64 Session::first(ChannelID id) qint64 Session::first(ChannelID id)
{ {
qint64 drift = qint64(PROFILE.cpap->clockDrift()) * 1000L; qint64 drift = qint64(p_profile->cpap->clockDrift()) * 1000L;
qint64 tmp; qint64 tmp;
QHash<ChannelID, quint64>::iterator i = m_firstchan.find(id); QHash<ChannelID, quint64>::iterator i = m_firstchan.find(id);
@ -1191,7 +1191,7 @@ qint64 Session::first(ChannelID id)
} }
qint64 Session::last(ChannelID id) qint64 Session::last(ChannelID id)
{ {
qint64 drift = qint64(PROFILE.cpap->clockDrift()) * 1000L; qint64 drift = qint64(p_profile->cpap->clockDrift()) * 1000L;
qint64 tmp; qint64 tmp;
QHash<ChannelID, quint64>::iterator i = m_lastchan.find(id); QHash<ChannelID, quint64>::iterator i = m_lastchan.find(id);
@ -1943,7 +1943,7 @@ qint64 Session::first()
qint64 start = s_first; qint64 start = s_first;
if (s_machine->GetType() == MT_CPAP) { if (s_machine->GetType() == MT_CPAP) {
start += qint64(PROFILE.cpap->clockDrift()) * 1000L; start += qint64(p_profile->cpap->clockDrift()) * 1000L;
} }
return start; return start;
@ -1954,7 +1954,7 @@ qint64 Session::last()
qint64 last = s_last; qint64 last = s_last;
if (s_machine->GetType() == MT_CPAP) { if (s_machine->GetType() == MT_CPAP) {
last += qint64(PROFILE.cpap->clockDrift()) * 1000L; last += qint64(p_profile->cpap->clockDrift()) * 1000L;
} }
return last; return last;

View File

@ -1 +1 @@
const int build_number = 1; const int build_number = 2;

View File

@ -129,7 +129,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
layout->addWidget(GraphView,1); layout->addWidget(GraphView,1);
layout->addWidget(scrollbar,0); layout->addWidget(scrollbar,0);
int default_height=PROFILE.appearance->graphHeight(); int default_height=p_profile->appearance->graphHeight();
gGraph *GAHI = nullptr, gGraph *GAHI = nullptr,
// *TAP = nullptr, // *TAP = nullptr,
@ -158,13 +158,13 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
graphlist[schema::channel[code].label()] = new gGraph(GraphView, schema::channel[code].label(), channelInfo(code), default_height); graphlist[schema::channel[code].label()] = new gGraph(GraphView, schema::channel[code].label(), channelInfo(code), default_height);
} }
int oxigrp=PROFILE.ExistsAndTrue("SyncOximetry") ? 0 : 1; // Contemplating killing this setting... int oxigrp=p_profile->ExistsAndTrue("SyncOximetry") ? 0 : 1; // Contemplating killing this setting...
for (int i=0; i < oxisize; ++i) { for (int i=0; i < oxisize; ++i) {
ChannelID code = oxicodes[i]; ChannelID code = oxicodes[i];
graphlist[schema::channel[code].label()] = new gGraph(GraphView, schema::channel[code].label(), channelInfo(code), default_height, oxigrp); graphlist[schema::channel[code].label()] = new gGraph(GraphView, schema::channel[code].label(), channelInfo(code), default_height, oxigrp);
} }
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
AHI=new gGraph(GraphView,STR_TR_RDI, channelInfo(CPAP_RDI), default_height); AHI=new gGraph(GraphView,STR_TR_RDI, channelInfo(CPAP_RDI), default_height);
} else { } else {
AHI=new gGraph(GraphView,STR_TR_AHI, channelInfo(CPAP_AHI), default_height); AHI=new gGraph(GraphView,STR_TR_AHI, channelInfo(CPAP_AHI), default_height);
@ -216,7 +216,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
fg->AddLayer((new gFlagsLine(CPAP_RERA, COLOR_RERA, STR_TR_RE))); fg->AddLayer((new gFlagsLine(CPAP_RERA, COLOR_RERA, STR_TR_RE)));
fg->AddLayer((new gFlagsLine(CPAP_VSnore, COLOR_VibratorySnore, STR_TR_VS))); fg->AddLayer((new gFlagsLine(CPAP_VSnore, COLOR_VibratorySnore, STR_TR_VS)));
fg->AddLayer((new gFlagsLine(CPAP_VSnore2, COLOR_VibratorySnore, STR_TR_VS2))); fg->AddLayer((new gFlagsLine(CPAP_VSnore2, COLOR_VibratorySnore, STR_TR_VS2)));
if (PROFILE.cpap->userEventFlagging()) { if (p_profile->cpap->userEventFlagging()) {
fg->AddLayer((new gFlagsLine(CPAP_UserFlag1, COLOR_Yellow, STR_TR_UF1))); fg->AddLayer((new gFlagsLine(CPAP_UserFlag1, COLOR_Yellow, STR_TR_UF1)));
fg->AddLayer((new gFlagsLine(CPAP_UserFlag2, COLOR_DarkGreen, STR_TR_UF2))); fg->AddLayer((new gFlagsLine(CPAP_UserFlag2, COLOR_DarkGreen, STR_TR_UF2)));
fg->AddLayer((new gFlagsLine(CPAP_UserFlag3, COLOR_Brown, STR_TR_UF3))); fg->AddLayer((new gFlagsLine(CPAP_UserFlag3, COLOR_Brown, STR_TR_UF3)));
@ -265,7 +265,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_0E,COLOR_DarkRed,"0E",FT_Dot))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(PRS1_0E,COLOR_DarkRed,"0E",FT_Dot)));
gLineOverlayBar * rera = new gLineOverlayBar(CPAP_RERA, COLOR_RERA, STR_TR_RE); gLineOverlayBar * rera = new gLineOverlayBar(CPAP_RERA, COLOR_RERA, STR_TR_RE);
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
FRW->AddLayer(AddCPAP(los->add(rera))); FRW->AddLayer(AddCPAP(los->add(rera)));
} else { } else {
FRW->AddLayer(AddCPAP(rera)); FRW->AddLayer(AddCPAP(rera));
@ -276,7 +276,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_SensAwake, COLOR_SensAwake, STR_TR_SA))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_SensAwake, COLOR_SensAwake, STR_TR_SA)));
FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Obstructive, COLOR_Obstructive, STR_TR_OA)))); FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_Obstructive, COLOR_Obstructive, STR_TR_OA))));
FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_ClearAirway, COLOR_ClearAirway, STR_TR_CA)))); FRW->AddLayer(AddCPAP(los->add(new gLineOverlayBar(CPAP_ClearAirway, COLOR_ClearAirway, STR_TR_CA))));
if (PROFILE.cpap->userEventFlagging()) { if (p_profile->cpap->userEventFlagging()) {
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_UserFlag1, COLOR_Yellow, tr("U1"),FT_Bar))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_UserFlag1, COLOR_Yellow, tr("U1"),FT_Bar)));
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_UserFlag2, COLOR_Orange, tr("U2"),FT_Bar))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_UserFlag2, COLOR_Orange, tr("U2"),FT_Bar)));
FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_UserFlag3, COLOR_Brown, tr("U3"),FT_Bar))); FRW->AddLayer(AddCPAP(new gLineOverlayBar(CPAP_UserFlag3, COLOR_Brown, tr("U3"),FT_Bar)));
@ -288,7 +288,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
FRW->AddLayer(AddCPAP(los)); FRW->AddLayer(AddCPAP(los));
bool square=PROFILE.appearance->squareWavePlots(); bool square=p_profile->appearance->squareWavePlots();
gLineChart *pc=new gLineChart(CPAP_Pressure, COLOR_Pressure, square); gLineChart *pc=new gLineChart(CPAP_Pressure, COLOR_Pressure, square);
graphlist[schema::channel[CPAP_Pressure].label()]->AddLayer(AddCPAP(pc)); graphlist[schema::channel[CPAP_Pressure].label()]->AddLayer(AddCPAP(pc));
pc->addPlot(CPAP_EPAP, COLOR_EPAP, square); pc->addPlot(CPAP_EPAP, COLOR_EPAP, square);
@ -296,7 +296,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
pc->addPlot(CPAP_IPAP, COLOR_IPAP, square); pc->addPlot(CPAP_IPAP, COLOR_IPAP, square);
pc->addPlot(CPAP_IPAPHi, COLOR_IPAPHi, square); pc->addPlot(CPAP_IPAPHi, COLOR_IPAPHi, square);
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
AHI->AddLayer(AddCPAP(new gLineChart(CPAP_RDI, COLOR_RDI, square))); AHI->AddLayer(AddCPAP(new gLineChart(CPAP_RDI, COLOR_RDI, square)));
// AHI->AddLayer(AddCPAP(new AHIChart(QColor("#37a24b")))); // AHI->AddLayer(AddCPAP(new AHIChart(QColor("#37a24b"))));
} else { } else {
@ -374,8 +374,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
it.value()->AddLayer(new gXAxis(),LayerBottom,0,20); it.value()->AddLayer(new gXAxis(),LayerBottom,0,20);
} }
if (PROFILE.cpap->showLeakRedline()) { if (p_profile->cpap->showLeakRedline()) {
schema::channel[CPAP_Leak].setUpperThreshold(PROFILE.cpap->leakRedline()); schema::channel[CPAP_Leak].setUpperThreshold(p_profile->cpap->leakRedline());
} else { } else {
schema::channel[CPAP_Leak].setUpperThreshold(0); // switch it off schema::channel[CPAP_Leak].setUpperThreshold(0); // switch it off
} }
@ -397,7 +397,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
connect(webView,SIGNAL(linkClicked(QUrl)),this,SLOT(Link_clicked(QUrl))); connect(webView,SIGNAL(linkClicked(QUrl)),this,SLOT(Link_clicked(QUrl)));
int ews=PROFILE.general->eventWindowSize(); int ews=p_profile->general->eventWindowSize();
ui->evViewSlider->setValue(ews); ui->evViewSlider->setValue(ews);
ui->evViewLCD->display(ews); ui->evViewLCD->display(ews);
@ -408,7 +408,7 @@ Daily::Daily(QWidget *parent,gGraphView * shared)
ui->splitter->setVisible(false); ui->splitter->setVisible(false);
if (PROFILE.general->unitSystem()==US_Archiac) { if (p_profile->general->unitSystem()==US_Archiac) {
ui->weightSpinBox->setSuffix(STR_UNIT_POUND); ui->weightSpinBox->setSuffix(STR_UNIT_POUND);
ui->weightSpinBox->setDecimals(0); ui->weightSpinBox->setDecimals(0);
ui->ouncesSpinBox->setVisible(true); ui->ouncesSpinBox->setVisible(true);
@ -457,7 +457,7 @@ void Daily::doToggleSession(Session * sess)
sess->setEnabled(!sess->enabled()); sess->setEnabled(!sess->enabled());
// sess->StoreSummary(); // sess->StoreSummary();
Day *day=PROFILE.GetDay(previous_date,MT_CPAP); Day *day=p_profile->GetDay(previous_date,MT_CPAP);
if (day) { if (day) {
day->machine->Save(); day->machine->Save();
this->LoadDate(previous_date); this->LoadDate(previous_date);
@ -471,7 +471,7 @@ void Daily::Link_clicked(const QUrl &url)
int sid=data.toInt(); int sid=data.toInt();
Day *day=nullptr; Day *day=nullptr;
if (code=="togglecpapsession") { // Enable/Disable CPAP session if (code=="togglecpapsession") { // Enable/Disable CPAP session
day=PROFILE.GetDay(previous_date,MT_CPAP); day=p_profile->GetDay(previous_date,MT_CPAP);
Session *sess=day->find(sid); Session *sess=day->find(sid);
if (!sess) if (!sess)
return; return;
@ -486,7 +486,7 @@ void Daily::Link_clicked(const QUrl &url)
webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical)-i); webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical)-i);
return; return;
} else if (code=="toggleoxisession") { // Enable/Disable Oximetry session } else if (code=="toggleoxisession") { // Enable/Disable Oximetry session
day=PROFILE.GetDay(previous_date,MT_OXIMETER); day=p_profile->GetDay(previous_date,MT_OXIMETER);
Session *sess=day->find(sid); Session *sess=day->find(sid);
if (!sess) if (!sess)
return; return;
@ -500,9 +500,9 @@ void Daily::Link_clicked(const QUrl &url)
webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical)-i); webView->page()->mainFrame()->setScrollBarValue(Qt::Vertical, webView->page()->mainFrame()->scrollBarMaximum(Qt::Vertical)-i);
return; return;
} else if (code=="cpap") { } else if (code=="cpap") {
day=PROFILE.GetDay(previous_date,MT_CPAP); day=p_profile->GetDay(previous_date,MT_CPAP);
} else if (code=="oxi") { } else if (code=="oxi") {
//day=PROFILE.GetDay(previous_date,MT_OXIMETER); //day=p_profile->GetDay(previous_date,MT_OXIMETER);
//Session *sess=day->machine->sessionlist[sid]; //Session *sess=day->machine->sessionlist[sid];
return; return;
} else if (code=="event") { } else if (code=="event") {
@ -541,7 +541,7 @@ void Daily::ReloadGraphs()
d=previous_date; d=previous_date;
// Unload(d); // Unload(d);
} }
d=PROFILE.LastDay(); d=p_profile->LastDay();
if (!d.isValid()) { if (!d.isValid()) {
d=ui->calendar->selectedDate(); d=ui->calendar->selectedDate();
} }
@ -579,7 +579,7 @@ void Daily::UpdateEventsTree(QTreeWidget *tree,Day *day)
int total_events=0; int total_events=0;
bool userflags=p_profile->cpap->userEventFlagging(); bool userflags=p_profile->cpap->userEventFlagging();
qint64 drift=0, clockdrift=PROFILE.cpap->clockDrift()*1000L; qint64 drift=0, clockdrift=p_profile->cpap->clockDrift()*1000L;
for (QList<Session *>::iterator s=day->begin();s!=day->end();++s) { for (QList<Session *>::iterator s=day->begin();s!=day->end();++s) {
if (!(*s)->enabled()) continue; if (!(*s)->enabled()) continue;
@ -704,11 +704,11 @@ void Daily::UpdateCalendarDay(QDate date)
nodata.setForeground(QBrush(COLOR_Black, Qt::SolidPattern)); nodata.setForeground(QBrush(COLOR_Black, Qt::SolidPattern));
nodata.setFontWeight(QFont::Normal); nodata.setFontWeight(QFont::Normal);
bool hascpap=PROFILE.GetDay(date,MT_CPAP)!=nullptr; bool hascpap=p_profile->GetDay(date,MT_CPAP)!=nullptr;
bool hasoxi=PROFILE.GetDay(date,MT_OXIMETER)!=nullptr; bool hasoxi=p_profile->GetDay(date,MT_OXIMETER)!=nullptr;
bool hasjournal=PROFILE.GetDay(date,MT_JOURNAL)!=nullptr; bool hasjournal=p_profile->GetDay(date,MT_JOURNAL)!=nullptr;
bool hasstage=PROFILE.GetDay(date,MT_SLEEPSTAGE)!=nullptr; bool hasstage=p_profile->GetDay(date,MT_SLEEPSTAGE)!=nullptr;
bool haspos=PROFILE.GetDay(date,MT_POSITION)!=nullptr; bool haspos=p_profile->GetDay(date,MT_POSITION)!=nullptr;
if (hascpap) { if (hascpap) {
if (hasoxi) { if (hasoxi) {
ui->calendar->setDateTextFormat(date,oxicpap); ui->calendar->setDateTextFormat(date,oxicpap);
@ -766,7 +766,7 @@ void Daily::on_calendar_selectionChanged()
ui->calButton->setText(ui->calendar->selectedDate().toString(Qt::TextDate)); ui->calButton->setText(ui->calendar->selectedDate().toString(Qt::TextDate));
ui->calendar->setFocus(Qt::ActiveWindowFocusReason); ui->calendar->setFocus(Qt::ActiveWindowFocusReason);
if (PROFILE.general->unitSystem()==US_Archiac) { if (p_profile->general->unitSystem()==US_Archiac) {
ui->weightSpinBox->setSuffix(STR_UNIT_POUND); ui->weightSpinBox->setSuffix(STR_UNIT_POUND);
ui->weightSpinBox->setDecimals(0); ui->weightSpinBox->setDecimals(0);
ui->ouncesSpinBox->setVisible(true); ui->ouncesSpinBox->setVisible(true);
@ -1112,15 +1112,15 @@ QString Daily::getStatisticsInfo(Day * cpap,Day * oxi,Day *pos)
list.push_back(pos); list.push_back(pos);
int mididx=PROFILE.general->prefCalcMiddle(); int mididx=p_profile->general->prefCalcMiddle();
SummaryType ST_mid; SummaryType ST_mid;
if (mididx==0) ST_mid=ST_PERC; if (mididx==0) ST_mid=ST_PERC;
if (mididx==1) ST_mid=ST_WAVG; if (mididx==1) ST_mid=ST_WAVG;
if (mididx==2) ST_mid=ST_AVG; if (mididx==2) ST_mid=ST_AVG;
float percentile=PROFILE.general->prefCalcPercentile()/100.0; float percentile=p_profile->general->prefCalcPercentile()/100.0;
SummaryType ST_max=PROFILE.general->prefCalcMax() ? ST_PERC : ST_MAX; SummaryType ST_max=p_profile->general->prefCalcMax() ? ST_PERC : ST_MAX;
const EventDataType maxperc=0.995F; const EventDataType maxperc=0.995F;
QString midname; QString midname;
@ -1212,8 +1212,8 @@ QString Daily::getStatisticsInfo(Day * cpap,Day * oxi,Day *pos)
html+="<tr><td colspan=5>&nbsp;</td></tr>\n"; html+="<tr><td colspan=5>&nbsp;</td></tr>\n";
html+=QString("<tr><td colspan=5 align=center><i>%1</i></td></tr>").arg("<b>"+STR_MessageBox_PleaseNote+"</b> "+ tr("This day just contains summary data, only limited information is available .")); html+=QString("<tr><td colspan=5 align=center><i>%1</i></td></tr>").arg("<b>"+STR_MessageBox_PleaseNote+"</b> "+ tr("This day just contains summary data, only limited information is available ."));
} else } else
if (cpap && PROFILE.cpap->showLeakRedline()) { if (cpap && p_profile->cpap->showLeakRedline()) {
float rlt = cpap->timeAboveThreshold(CPAP_Leak, PROFILE.cpap->leakRedline()) / 60.0; float rlt = cpap->timeAboveThreshold(CPAP_Leak, p_profile->cpap->leakRedline()) / 60.0;
float pc = 100.0 / cpap->hours() * rlt; float pc = 100.0 / cpap->hours() * rlt;
html+="<tr><td colspan=5>&nbsp;</td></tr>"; html+="<tr><td colspan=5>&nbsp;</td></tr>";
html+="<tr><td colspan=3 align='left' bgcolor='white'><b>"+tr("Time over leak redline")+ html+="<tr><td colspan=3 align='left' bgcolor='white'><b>"+tr("Time over leak redline")+
@ -1271,12 +1271,12 @@ void Daily::Load(QDate date)
{ {
dateDisplay->setText("<i>"+date.toString(Qt::SystemLocaleLongDate)+"</i>"); dateDisplay->setText("<i>"+date.toString(Qt::SystemLocaleLongDate)+"</i>");
previous_date=date; previous_date=date;
Day *cpap=PROFILE.GetDay(date,MT_CPAP); Day *cpap=p_profile->GetDay(date,MT_CPAP);
Day *oxi=PROFILE.GetDay(date,MT_OXIMETER); Day *oxi=p_profile->GetDay(date,MT_OXIMETER);
Day *stage=PROFILE.GetDay(date,MT_SLEEPSTAGE); Day *stage=p_profile->GetDay(date,MT_SLEEPSTAGE);
Day *posit=PROFILE.GetDay(date,MT_POSITION); Day *posit=p_profile->GetDay(date,MT_POSITION);
if (!PROFILE.session->cacheSessions()) { if (!p_profile->session->cacheSessions()) {
// Getting trashed on purge last day... // Getting trashed on purge last day...
// lastcpapday can get purged and be invalid // lastcpapday can get purged and be invalid
@ -1349,7 +1349,7 @@ void Daily::Load(QDate date)
if (cpap) { if (cpap) {
float hours=cpap->hours(); float hours=cpap->hours();
if (GraphView->isEmpty() && (hours>0)) { if (GraphView->isEmpty() && (hours>0)) {
if (!PROFILE.hasChannel(CPAP_Obstructive) && !PROFILE.hasChannel(CPAP_Hypopnea)) { if (!p_profile->hasChannel(CPAP_Obstructive) && !p_profile->hasChannel(CPAP_Hypopnea)) {
GraphView->setEmptyText(tr("No Graphs :(")); GraphView->setEmptyText(tr("No Graphs :("));
isBrick=true; isBrick=true;
@ -1361,7 +1361,7 @@ void Daily::Load(QDate date)
modestr=schema::channel[CPAP_Mode].m_options[mode]; modestr=schema::channel[CPAP_Mode].m_options[mode];
EventDataType ahi=(cpap->count(CPAP_Obstructive)+cpap->count(CPAP_Hypopnea)+cpap->count(CPAP_ClearAirway)+cpap->count(CPAP_Apnea)); EventDataType ahi=(cpap->count(CPAP_Obstructive)+cpap->count(CPAP_Hypopnea)+cpap->count(CPAP_ClearAirway)+cpap->count(CPAP_Apnea));
if (PROFILE.general->calculateRDI()) ahi+=cpap->count(CPAP_RERA); if (p_profile->general->calculateRDI()) ahi+=cpap->count(CPAP_RERA);
ahi/=hours; ahi/=hours;
EventDataType csr,uai,oai,hi,cai,rei,fli,sai,nri,lki,vs,vs2,exp,lk2; EventDataType csr,uai,oai,hi,cai,rei,fli,sai,nri,lki,vs,vs2,exp,lk2;
@ -1369,7 +1369,7 @@ void Daily::Load(QDate date)
html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"; html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n";
ChannelID ahichan=CPAP_AHI; ChannelID ahichan=CPAP_AHI;
QString ahiname=STR_TR_AHI; QString ahiname=STR_TR_AHI;
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
ahichan=CPAP_RDI; ahichan=CPAP_RDI;
ahiname=STR_TR_RDI; ahiname=STR_TR_RDI;
} }
@ -1422,7 +1422,7 @@ void Daily::Load(QDate date)
html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"; html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n";
// Show Event Breakdown pie chart // Show Event Breakdown pie chart
if ((hours > 0) && PROFILE.appearance->graphSnapshots()) { // AHI Pie Chart if ((hours > 0) && p_profile->appearance->graphSnapshots()) { // AHI Pie Chart
if ((oai+hi+cai+uai+rei+fli+sai)>0) { if ((oai+hi+cai+uai+rei+fli+sai)>0) {
html+="<tr><td align=center>&nbsp;</td></tr>"; html+="<tr><td align=center>&nbsp;</td></tr>";
html+=QString("<tr><td align=center><b>%1</b></td></tr>").arg(tr("Event Breakdown")); html+=QString("<tr><td align=center><b>%1</b></td></tr>").arg(tr("Event Breakdown"));
@ -1556,7 +1556,7 @@ void Daily::Load(QDate date)
if (journal->settings.contains(Journal_Weight)) { if (journal->settings.contains(Journal_Weight)) {
double kg=journal->settings[Journal_Weight].toDouble(&ok); double kg=journal->settings[Journal_Weight].toDouble(&ok);
if (PROFILE.general->unitSystem()==US_Metric) { if (p_profile->general->unitSystem()==US_Metric) {
ui->weightSpinBox->setDecimals(3); ui->weightSpinBox->setDecimals(3);
ui->weightSpinBox->blockSignals(true); ui->weightSpinBox->blockSignals(true);
ui->weightSpinBox->setValue(kg); ui->weightSpinBox->setValue(kg);
@ -1581,7 +1581,7 @@ void Daily::Load(QDate date)
ui->ouncesSpinBox->setVisible(true); ui->ouncesSpinBox->setVisible(true);
ui->ouncesSpinBox->setSuffix(STR_UNIT_OUNCE); ui->ouncesSpinBox->setSuffix(STR_UNIT_OUNCE);
} }
double height=PROFILE.user->height()/100.0; double height=p_profile->user->height()/100.0;
if (height>0 && kg>0) { if (height>0 && kg>0) {
double bmi=kg/(height*height); double bmi=kg/(height*height);
ui->BMI->setVisible(true); ui->BMI->setVisible(true);
@ -1604,8 +1604,8 @@ void Daily::Load(QDate date)
ui->bookmarkTable->blockSignals(true); ui->bookmarkTable->blockSignals(true);
qint64 clockdrift=PROFILE.cpap->clockDrift()*1000L,drift; qint64 clockdrift=p_profile->cpap->clockDrift()*1000L,drift;
Day * dday=PROFILE.GetDay(previous_date,MT_CPAP); Day * dday=p_profile->GetDay(previous_date,MT_CPAP);
drift=(dday!=nullptr) ? clockdrift : 0; drift=(dday!=nullptr) ? clockdrift : 0;
bool ok; bool ok;
@ -1632,7 +1632,7 @@ void Daily::Load(QDate date)
void Daily::UnitsChanged() void Daily::UnitsChanged()
{ {
double kg; double kg;
if (PROFILE.general->unitSystem()==US_Archiac) { if (p_profile->general->unitSystem()==US_Archiac) {
kg=ui->weightSpinBox->value(); kg=ui->weightSpinBox->value();
float ounces=(kg*1000.0)/ounce_convert; float ounces=(kg*1000.0)/ounce_convert;
int pounds=ounces/16; int pounds=ounces/16;
@ -1691,7 +1691,7 @@ void Daily::Unload(QDate date)
if (journal->IsChanged()) { if (journal->IsChanged()) {
// blah.. was updating overview graphs here.. Was too slow. // blah.. was updating overview graphs here.. Was too slow.
} }
Machine *jm=PROFILE.GetMachine(MT_JOURNAL); Machine *jm=p_profile->GetMachine(MT_JOURNAL);
if (jm) jm->SaveSession(journal); if (jm) jm->SaveSession(journal);
} }
UpdateCalendarDay(date); UpdateCalendarDay(date);
@ -1774,17 +1774,17 @@ void Daily::on_JournalNotesColour_clicked()
} }
Session * Daily::CreateJournalSession(QDate date) Session * Daily::CreateJournalSession(QDate date)
{ {
Machine *m=PROFILE.GetMachine(MT_JOURNAL); Machine *m=p_profile->GetMachine(MT_JOURNAL);
if (!m) { if (!m) {
m=new Machine(p_profile,0); m=new Machine(0);
m->SetClass("Journal"); m->SetClass("Journal");
m->properties[STR_PROP_Brand]="Virtual"; m->properties[STR_PROP_Brand]="Virtual";
m->SetType(MT_JOURNAL); m->SetType(MT_JOURNAL);
PROFILE.AddMachine(m); p_profile->AddMachine(m);
} }
Session *sess=new Session(m,0); Session *sess=new Session(m,0);
qint64 st,et; qint64 st,et;
Day *cday=PROFILE.GetDay(date,MT_CPAP); Day *cday=p_profile->GetDay(date,MT_CPAP);
if (cday) { if (cday) {
st=cday->first(); st=cday->first();
et=cday->last(); et=cday->last();
@ -1796,12 +1796,12 @@ Session * Daily::CreateJournalSession(QDate date)
sess->set_first(st); sess->set_first(st);
sess->set_last(et); sess->set_last(et);
sess->SetChanged(true); sess->SetChanged(true);
m->AddSession(sess,p_profile); m->AddSession(sess);
return sess; return sess;
} }
Session * Daily::GetJournalSession(QDate date) // Get the first journal session Session * Daily::GetJournalSession(QDate date) // Get the first journal session
{ {
Day *journal=PROFILE.GetDay(date,MT_JOURNAL); Day *journal=p_profile->GetDay(date,MT_JOURNAL);
if (!journal) if (!journal)
return nullptr; //CreateJournalSession(date); return nullptr; //CreateJournalSession(date);
QList<Session *>::iterator s; QList<Session *>::iterator s;
@ -1858,8 +1858,8 @@ void Daily::UpdateOXIGraphs(Day *day)
void Daily::RedrawGraphs() void Daily::RedrawGraphs()
{ {
// setting this here, because it needs to be done when preferences change // setting this here, because it needs to be done when preferences change
if (PROFILE.cpap->showLeakRedline()) { if (p_profile->cpap->showLeakRedline()) {
schema::channel[CPAP_Leak].setUpperThreshold(PROFILE.cpap->leakRedline()); schema::channel[CPAP_Leak].setUpperThreshold(p_profile->cpap->leakRedline());
} else { } else {
schema::channel[CPAP_Leak].setUpperThreshold(0); // switch it off schema::channel[CPAP_Leak].setUpperThreshold(0); // switch it off
} }
@ -1872,7 +1872,7 @@ void Daily::on_treeWidget_itemClicked(QTreeWidgetItem *item, int column)
Q_UNUSED(column); Q_UNUSED(column);
QDateTime d; QDateTime d;
if (!item->data(0,Qt::UserRole).isNull()) { if (!item->data(0,Qt::UserRole).isNull()) {
qint64 winsize=qint64(PROFILE.general->eventWindowSize())*60000L; qint64 winsize=qint64(p_profile->general->eventWindowSize())*60000L;
qint64 t=item->data(0,Qt::UserRole).toLongLong(); qint64 t=item->data(0,Qt::UserRole).toLongLong();
double st=t-(winsize/2); double st=t-(winsize/2);
@ -1917,13 +1917,13 @@ void Daily::on_JournalNotesUnderline_clicked()
void Daily::on_prevDayButton_clicked() void Daily::on_prevDayButton_clicked()
{ {
if (!PROFILE.ExistsAndTrue("SkipEmptyDays")) { if (!p_profile->ExistsAndTrue("SkipEmptyDays")) {
LoadDate(previous_date.addDays(-1)); LoadDate(previous_date.addDays(-1));
} else { } else {
QDate d=previous_date; QDate d=previous_date;
for (int i=0;i<90;i++) { for (int i=0;i<90;i++) {
d=d.addDays(-1); d=d.addDays(-1);
if (PROFILE.GetDay(d)) { if (p_profile->GetDay(d)) {
LoadDate(d); LoadDate(d);
break; break;
} }
@ -1933,13 +1933,13 @@ void Daily::on_prevDayButton_clicked()
void Daily::on_nextDayButton_clicked() void Daily::on_nextDayButton_clicked()
{ {
if (!PROFILE.ExistsAndTrue("SkipEmptyDays")) { if (!p_profile->ExistsAndTrue("SkipEmptyDays")) {
LoadDate(previous_date.addDays(1)); LoadDate(previous_date.addDays(1));
} else { } else {
QDate d=previous_date; QDate d=previous_date;
for (int i=0;i<90;i++) { for (int i=0;i<90;i++) {
d=d.addDays(1); d=d.addDays(1);
if (PROFILE.GetDay(d)) { if (p_profile->GetDay(d)) {
LoadDate(d); LoadDate(d);
break; break;
} }
@ -1963,14 +1963,14 @@ void Daily::on_calButton_toggled(bool checked)
void Daily::on_todayButton_clicked() void Daily::on_todayButton_clicked()
{ {
QDate d=QDate::currentDate(); QDate d=QDate::currentDate();
if (d > PROFILE.LastDay()) d=PROFILE.LastDay(); if (d > p_profile->LastDay()) d=p_profile->LastDay();
LoadDate(d); LoadDate(d);
} }
void Daily::on_evViewSlider_valueChanged(int value) void Daily::on_evViewSlider_valueChanged(int value)
{ {
ui->evViewLCD->display(value); ui->evViewLCD->display(value);
PROFILE.general->setEventWindowSize(value); p_profile->general->setEventWindowSize(value);
int winsize=value*60; int winsize=value*60;
@ -1999,8 +1999,8 @@ void Daily::on_bookmarkTable_itemClicked(QTableWidgetItem *item)
int row=item->row(); int row=item->row();
qint64 st,et; qint64 st,et;
// qint64 clockdrift=PROFILE.cpap->clockDrift()*1000L,drift; // qint64 clockdrift=p_profile->cpap->clockDrift()*1000L,drift;
// Day * dday=PROFILE.GetDay(previous_date,MT_CPAP); // Day * dday=p_profile->GetDay(previous_date,MT_CPAP);
// drift=(dday!=nullptr) ? clockdrift : 0; // drift=(dday!=nullptr) ? clockdrift : 0;
QTableWidgetItem *it=ui->bookmarkTable->item(row,1); QTableWidgetItem *it=ui->bookmarkTable->item(row,1);
@ -2008,12 +2008,12 @@ void Daily::on_bookmarkTable_itemClicked(QTableWidgetItem *item)
st=it->data(Qt::UserRole).toLongLong(&ok); st=it->data(Qt::UserRole).toLongLong(&ok);
et=it->data(Qt::UserRole+1).toLongLong(&ok); et=it->data(Qt::UserRole+1).toLongLong(&ok);
qint64 st2=0,et2=0,st3,et3; qint64 st2=0,et2=0,st3,et3;
Day * day=PROFILE.GetGoodDay(previous_date,MT_CPAP); Day * day=p_profile->GetGoodDay(previous_date,MT_CPAP);
if (day) { if (day) {
st2=day->first(); st2=day->first();
et2=day->last(); et2=day->last();
} }
Day * oxi=PROFILE.GetGoodDay(previous_date,MT_OXIMETER); Day * oxi=p_profile->GetGoodDay(previous_date,MT_OXIMETER);
if (oxi) { if (oxi) {
st3=oxi->first(); st3=oxi->first();
et3=oxi->last(); et3=oxi->last();
@ -2049,8 +2049,8 @@ void Daily::on_addBookmarkButton_clicked()
dw->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled); dw->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
ui->bookmarkTable->setItem(row,0,dw); ui->bookmarkTable->setItem(row,0,dw);
ui->bookmarkTable->setItem(row,1,tw); ui->bookmarkTable->setItem(row,1,tw);
qint64 clockdrift=PROFILE.cpap->clockDrift()*1000L,drift; qint64 clockdrift=p_profile->cpap->clockDrift()*1000L,drift;
Day * day=PROFILE.GetDay(previous_date,MT_CPAP); Day * day=p_profile->GetDay(previous_date,MT_CPAP);
drift=(day!=nullptr) ? clockdrift : 0; drift=(day!=nullptr) ? clockdrift : 0;
// Counter CPAP clock drift for storage, in case user changes it later on // Counter CPAP clock drift for storage, in case user changes it later on
@ -2127,10 +2127,10 @@ void Daily::on_weightSpinBox_valueChanged(double arg1)
{ {
// Update the BMI display // Update the BMI display
double kg; double kg;
if (PROFILE.general->unitSystem()==US_Archiac) { if (p_profile->general->unitSystem()==US_Archiac) {
kg=((arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert)) / 1000.0; kg=((arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert)) / 1000.0;
} else kg=arg1; } else kg=arg1;
double height=PROFILE.user->height()/100.0; double height=p_profile->user->height()/100.0;
if ((height>0) && (kg>0)) { if ((height>0) && (kg>0)) {
double bmi=kg/(height * height); double bmi=kg/(height * height);
ui->BMI->display(bmi); ui->BMI->display(bmi);
@ -2142,14 +2142,14 @@ void Daily::on_weightSpinBox_editingFinished()
{ {
double arg1=ui->weightSpinBox->value(); double arg1=ui->weightSpinBox->value();
double height=PROFILE.user->height()/100.0; double height=p_profile->user->height()/100.0;
Session *journal=GetJournalSession(previous_date); Session *journal=GetJournalSession(previous_date);
if (!journal) { if (!journal) {
journal=CreateJournalSession(previous_date); journal=CreateJournalSession(previous_date);
} }
double kg; double kg;
if (PROFILE.general->unitSystem()==US_Archiac) { if (p_profile->general->unitSystem()==US_Archiac) {
kg=((arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert)) / 1000.0; kg=((arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert)) / 1000.0;
} else { } else {
kg=arg1; kg=arg1;
@ -2177,7 +2177,7 @@ void Daily::on_weightSpinBox_editingFinished()
void Daily::on_ouncesSpinBox_valueChanged(int arg1) void Daily::on_ouncesSpinBox_valueChanged(int arg1)
{ {
// just update for BMI display // just update for BMI display
double height=PROFILE.user->height()/100.0; double height=p_profile->user->height()/100.0;
double kg=((ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert)) / 1000.0; double kg=((ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert)) / 1000.0;
if ((height>0) && (kg>0)) { if ((height>0) && (kg>0)) {
double bmi=kg/(height * height); double bmi=kg/(height * height);
@ -2193,7 +2193,7 @@ void Daily::on_ouncesSpinBox_editingFinished()
if (!journal) { if (!journal) {
journal=CreateJournalSession(previous_date); journal=CreateJournalSession(previous_date);
} }
double height=PROFILE.user->height()/100.0; double height=p_profile->user->height()/100.0;
double kg=((ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert)) / 1000.0; double kg=((ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert)) / 1000.0;
journal->settings[Journal_Weight]=kg; journal->settings[Journal_Weight]=kg;

View File

@ -14,6 +14,7 @@ There is still an issue involving time splits for late sleepers who use ResMed m
<br/> <br/>
<b>New features & bug fixes in v0.9.7</b><br/> <b>New features & bug fixes in v0.9.7</b><br/>
<list> <list>
<li>Fixed a rare PRS1 duplicate session issue affecting multi-chunk files</li>
<li>Fixed ResMed STR.edf DST crossover bug causing duplicate sessions</li> <li>Fixed ResMed STR.edf DST crossover bug causing duplicate sessions</li>
<li>Added PRS1 SD Card automatic backup functionality</li> <li>Added PRS1 SD Card automatic backup functionality</li>
<li>Stopped faulty statistics calculations where only summary data was present (For now it should show zero where calculations are impossible)</li> <li>Stopped faulty statistics calculations where only summary data was present (For now it should show zero where calculations are impossible)</li>

View File

@ -74,7 +74,7 @@ ExportCSV::~ExportCSV()
void ExportCSV::on_filenameBrowseButton_clicked() void ExportCSV::on_filenameBrowseButton_clicked()
{ {
QString timestamp = tr("SleepyHead_"); QString timestamp = tr("SleepyHead_");
timestamp += PROFILE.Get("Username") + "_"; timestamp += p_profile->Get("Username") + "_";
if (ui->rb1_details->isChecked()) { timestamp += tr("Details_"); } if (ui->rb1_details->isChecked()) { timestamp += tr("Details_"); }
@ -105,8 +105,8 @@ void ExportCSV::on_filenameBrowseButton_clicked()
void ExportCSV::on_quickRangeCombo_activated(const QString &arg1) void ExportCSV::on_quickRangeCombo_activated(const QString &arg1)
{ {
QDate first = PROFILE.FirstDay(); QDate first = p_profile->FirstDay();
QDate last = PROFILE.LastDay(); QDate last = p_profile->LastDay();
if (arg1 == tr("Custom")) { if (arg1 == tr("Custom")) {
ui->startDate->setEnabled(true); ui->startDate->setEnabled(true);
@ -226,13 +226,13 @@ void ExportCSV::on_exportButton_clicked()
QDate daily_date = daily->getDate(); QDate daily_date = daily->getDate();
ui->progressBar->setValue(0); ui->progressBar->setValue(0);
ui->progressBar->setMaximum(PROFILE.daylist.count()); ui->progressBar->setMaximum(p_profile->daylist.count());
do { do {
ui->progressBar->setValue(ui->progressBar->value() + 1); ui->progressBar->setValue(ui->progressBar->value() + 1);
QApplication::processEvents(); QApplication::processEvents();
Day *day = PROFILE.GetDay(date, MT_CPAP); Day *day = p_profile->GetDay(date, MT_CPAP);
if (day) { if (day) {
QString data; QString data;

View File

@ -203,7 +203,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->statusbar->addPermanentWidget(qprogress, 1); ui->statusbar->addPermanentWidget(qprogress, 1);
ui->statusbar->addPermanentWidget(qstatus2, 0); ui->statusbar->addPermanentWidget(qstatus2, 0);
ui->actionDebug->setChecked(PROFILE.general->showDebug()); ui->actionDebug->setChecked(p_profile->general->showDebug());
QTextCharFormat format = ui->statStartDate->calendarWidget()->weekdayTextFormat(Qt::Saturday); QTextCharFormat format = ui->statStartDate->calendarWidget()->weekdayTextFormat(Qt::Saturday);
format.setForeground(QBrush(Qt::black, Qt::SolidPattern)); format.setForeground(QBrush(Qt::black, Qt::SolidPattern));
@ -221,7 +221,7 @@ MainWindow::MainWindow(QWidget *parent) :
ui->statStartDate->setVisible(false); ui->statStartDate->setVisible(false);
ui->reportModeRange->setVisible(false); ui->reportModeRange->setVisible(false);
switch(PROFILE.general->statReportMode()) { switch(p_profile->general->statReportMode()) {
case 0: case 0:
ui->reportModeStandard->setChecked(true); ui->reportModeStandard->setChecked(true);
break; break;
@ -234,16 +234,16 @@ MainWindow::MainWindow(QWidget *parent) :
ui->statStartDate->setVisible(true); ui->statStartDate->setVisible(true);
break; break;
default: default:
PROFILE.general->setStatReportMode(0); p_profile->general->setStatReportMode(0);
} }
if (!PROFILE.general->showDebug()) { if (!p_profile->general->showDebug()) {
ui->logText->hide(); ui->logText->hide();
} }
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
PROFILE.appearance->setAntiAliasing(false); p_profile->appearance->setAntiAliasing(false);
#endif #endif
ui->action_Link_Graph_Groups->setChecked(PROFILE.general->linkGroups()); ui->action_Link_Graph_Groups->setChecked(p_profile->general->linkGroups());
first_load = true; first_load = true;
@ -282,8 +282,8 @@ MainWindow::MainWindow(QWidget *parent) :
ui->toolBox->setCurrentIndex(0); ui->toolBox->setCurrentIndex(0);
daily->graphView()->redraw(); daily->graphView()->redraw();
if (PROFILE.cpap->AHIWindow() < 30.0) { if (p_profile->cpap->AHIWindow() < 30.0) {
PROFILE.cpap->setAHIWindow(60.0); p_profile->cpap->setAHIWindow(60.0);
} }
ui->recordsBox->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); ui->recordsBox->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
@ -377,7 +377,7 @@ void MainWindow::PopulatePurgeMenu()
ui->menu_Purge_CPAP_Data->clear(); ui->menu_Purge_CPAP_Data->clear();
QList<Machine *> machines = PROFILE.GetMachines(MT_CPAP); QList<Machine *> machines = p_profile->GetMachines(MT_CPAP);
for (int i=0; i < machines.size(); ++i) { for (int i=0; i < machines.size(); ++i) {
Machine *mach = machines.at(i); Machine *mach = machines.at(i);
QString name = mach->properties[STR_PROP_Brand]+" "+ QString name = mach->properties[STR_PROP_Brand]+" "+
@ -398,7 +398,7 @@ void MainWindow::Startup()
//qstatusbar->showMessage(tr("Loading Data"),0); //qstatusbar->showMessage(tr("Loading Data"),0);
// profile is a global variable set in main after login // profile is a global variable set in main after login
PROFILE.LoadMachineData(); p_profile->LoadMachineData();
PopulatePurgeMenu(); PopulatePurgeMenu();
@ -418,8 +418,8 @@ void MainWindow::Startup()
GenerateStatistics(); GenerateStatistics();
ui->tabWidget->setCurrentWidget(ui->statisticsTab); ui->tabWidget->setCurrentWidget(ui->statisticsTab);
ui->statStartDate->setDate(PROFILE.FirstDay()); ui->statStartDate->setDate(p_profile->FirstDay());
ui->statEndDate->setDate(PROFILE.LastDay()); ui->statEndDate->setDate(p_profile->LastDay());
if (daily) { daily->ReloadGraphs(); } if (daily) { daily->ReloadGraphs(); }
@ -428,9 +428,9 @@ void MainWindow::Startup()
qprogress->hide(); qprogress->hide();
qstatus->setText(""); qstatus->setText("");
if (PROFILE.p_preferences[STR_PREF_ReimportBackup].toBool()) { if (p_profile->p_preferences[STR_PREF_ReimportBackup].toBool()) {
importCPAPBackups(); importCPAPBackups();
PROFILE.p_preferences[STR_PREF_ReimportBackup]=false; p_profile->p_preferences[STR_PREF_ReimportBackup]=false;
} }
} }
@ -443,7 +443,7 @@ int MainWindow::importCPAP(const QString &path, const QString &message)
waitlayout.addWidget(qprogress,1); waitlayout.addWidget(qprogress,1);
qprogress->setVisible(true); qprogress->setVisible(true);
popup.show(); popup.show();
int c=PROFILE.Import(path); int c=p_profile->Import(path);
popup.hide(); popup.hide();
ui->statusbar->insertWidget(2,qprogress,1); ui->statusbar->insertWidget(2,qprogress,1);
qprogress->setVisible(false); qprogress->setVisible(false);
@ -453,7 +453,7 @@ int MainWindow::importCPAP(const QString &path, const QString &message)
void MainWindow::finishCPAPImport() void MainWindow::finishCPAPImport()
{ {
PROFILE.Save(); p_profile->Save();
GenerateStatistics(); GenerateStatistics();
if (overview) { overview->ReloadGraphs(); } if (overview) { overview->ReloadGraphs(); }
@ -464,11 +464,11 @@ void MainWindow::importCPAPBackups()
{ {
// Get BackupPaths for all CPAP machines // Get BackupPaths for all CPAP machines
QList<Machine *> machlist = PROFILE.GetMachines(MT_CPAP); QList<Machine *> machlist = p_profile->GetMachines(MT_CPAP);
QStringList paths; QStringList paths;
Q_FOREACH(Machine *m, machlist) { Q_FOREACH(Machine *m, machlist) {
if (m->properties.contains(STR_PROP_BackupPath)) { if (m->properties.contains(STR_PROP_BackupPath)) {
paths.push_back(PROFILE.Get(m->properties[STR_PROP_BackupPath])); paths.push_back(p_profile->Get(m->properties[STR_PROP_BackupPath]));
} }
} }
@ -758,7 +758,7 @@ void MainWindow::on_action_Import_Data_triggered()
qprogress->setValue(0); qprogress->setValue(0);
qprogress->show(); qprogress->show();
qstatus->setText(tr("Importing Data")); qstatus->setText(tr("Importing Data"));
int c = PROFILE.Import(dir); int c = p_profile->Import(dir);
qDebug() << "Finished Importing data" << c; qDebug() << "Finished Importing data" << c;
if (c) { if (c) {
@ -937,7 +937,7 @@ void MainWindow::on_homeButton_clicked()
void MainWindow::updateFavourites() void MainWindow::updateFavourites()
{ {
QDate date = PROFILE.LastDay(MT_JOURNAL); QDate date = p_profile->LastDay(MT_JOURNAL);
if (!date.isValid()) { if (!date.isValid()) {
return; return;
@ -952,7 +952,7 @@ void MainWindow::updateFavourites()
"<table width=100% cellpadding=2 cellspacing=0>"; "<table width=100% cellpadding=2 cellspacing=0>";
do { do {
Day *journal = PROFILE.GetDay(date, MT_JOURNAL); Day *journal = p_profile->GetDay(date, MT_JOURNAL);
if (journal) { if (journal) {
if (journal->size() > 0) { if (journal->size() > 0) {
@ -993,7 +993,7 @@ void MainWindow::updateFavourites()
} }
date = date.addDays(-1); date = date.addDays(-1);
} while (date >= PROFILE.FirstDay(MT_JOURNAL)); } while (date >= p_profile->FirstDay(MT_JOURNAL));
html += "</table></body></html>"; html += "</table></body></html>";
ui->bookmarkView->setHtml(html); ui->bookmarkView->setHtml(html);
@ -1203,7 +1203,7 @@ void MainWindow::on_action_About_triggered()
void MainWindow::on_actionDebug_toggled(bool checked) void MainWindow::on_actionDebug_toggled(bool checked)
{ {
PROFILE.general->setShowDebug(checked); p_profile->general->setShowDebug(checked);
logger->strlock.lock(); logger->strlock.lock();
if (checked) { if (checked) {
@ -1349,7 +1349,7 @@ void MainWindow::on_actionPrint_Report_triggered()
datestr = QDateTime::currentDateTime().toString(Qt::ISODate); datestr = QDateTime::currentDateTime().toString(Qt::ISODate);
} else { name = "Unknown"; } } else { name = "Unknown"; }
QString filename = PREF.Get("{home}/" + name + "_" + PROFILE.user->userName() + "_" + datestr + ".pdf"); QString filename = PREF.Get("{home}/" + name + "_" + p_profile->user->userName() + "_" + datestr + ".pdf");
printer.setOutputFileName(filename); printer.setOutputFileName(filename);
#endif #endif
@ -1388,7 +1388,7 @@ void MainWindow::on_action_Edit_Profile_triggered()
void MainWindow::on_action_Link_Graph_Groups_toggled(bool arg1) void MainWindow::on_action_Link_Graph_Groups_toggled(bool arg1)
{ {
PROFILE.general->setLinkGroups(arg1); p_profile->general->setLinkGroups(arg1);
if (daily) { daily->RedrawGraphs(); } if (daily) { daily->RedrawGraphs(); }
} }
@ -1503,11 +1503,11 @@ void MainWindow::on_action_Rebuild_Oximetry_Index_triggered()
QVector<ChannelID> invalid; QVector<ChannelID> invalid;
QList<Machine *> machines = PROFILE.GetMachines(MT_OXIMETER); QList<Machine *> machines = p_profile->GetMachines(MT_OXIMETER);
qint64 f = 0, l = 0; qint64 f = 0, l = 0;
int discard_threshold = PROFILE.oxi->oxiDiscardThreshold(); int discard_threshold = p_profile->oxi->oxiDiscardThreshold();
Machine *m; Machine *m;
for (int z = 0; z < machines.size(); z++) { for (int z = 0; z < machines.size(); z++) {
@ -1690,7 +1690,7 @@ void MainWindow::RestartApplication(bool force_login, bool change_datafolder)
void MainWindow::on_actionChange_User_triggered() void MainWindow::on_actionChange_User_triggered()
{ {
PROFILE.Save(); p_profile->Save();
PREF.Save(); PREF.Save();
RestartApplication(true); RestartApplication(true);
} }
@ -1698,12 +1698,12 @@ void MainWindow::on_actionChange_User_triggered()
void MainWindow::on_actionPurge_Current_Day_triggered() void MainWindow::on_actionPurge_Current_Day_triggered()
{ {
QDate date = getDaily()->getDate(); QDate date = getDaily()->getDate();
Day *day = PROFILE.GetDay(date, MT_CPAP); Day *day = p_profile->GetDay(date, MT_CPAP);
Machine *m; Machine *m;
if (day) { if (day) {
m = day->machine; m = day->machine;
QString path = PROFILE.Get("{" + STR_GEN_DataFolder + "}/") + m->GetClass() + "_" + QString path = p_profile->Get("{" + STR_GEN_DataFolder + "}/") + m->GetClass() + "_" +
m->properties[STR_PROP_Serial] + "/"; m->properties[STR_PROP_Serial] + "/";
QList<Session *>::iterator s; QList<Session *>::iterator s;
@ -1731,7 +1731,7 @@ void MainWindow::on_actionPurge_Current_Day_triggered()
delete sess; delete sess;
} }
QList<Day *> &dl = PROFILE.daylist[date]; QList<Day *> &dl = p_profile->daylist[date];
QList<Day *>::iterator it;//=dl.begin(); QList<Day *>::iterator it;//=dl.begin();
for (it = dl.begin(); it != dl.end(); it++) { for (it = dl.begin(); it != dl.end(); it++) {
@ -1740,7 +1740,7 @@ void MainWindow::on_actionPurge_Current_Day_triggered()
if (it != dl.end()) { if (it != dl.end()) {
dl.erase(it); dl.erase(it);
//PROFILE.daylist[date]. // ?? //p_profile->daylist[date]. // ??
delete day; delete day;
} }
} }
@ -1754,7 +1754,7 @@ void MainWindow::on_actionPurgeMachine(QAction *action)
QString data = action->data().toString(); QString data = action->data().toString();
QString cls = data.section(":",0,0); QString cls = data.section(":",0,0);
QString serial = data.section(":", 1); QString serial = data.section(":", 1);
QList<Machine *> machines = PROFILE.GetMachines(MT_CPAP); QList<Machine *> machines = p_profile->GetMachines(MT_CPAP);
Machine * mach = nullptr; Machine * mach = nullptr;
for (int i=0; i < machines.size(); ++i) { for (int i=0; i < machines.size(); ++i) {
Machine * m = machines.at(i); Machine * m = machines.at(i);
@ -1788,7 +1788,7 @@ void MainWindow::purgeMachine(Machine * mach)
QMessageBox::warning(this, STR_MessageBox_Error, QMessageBox::warning(this, STR_MessageBox_Error,
tr("Not all session data could be removed, you have to delete the following folder manually.") tr("Not all session data could be removed, you have to delete the following folder manually.")
+"\n\n"+ +"\n\n"+
QDir::toNativeSeparators(PROFILE.Get(mach->properties[STR_PROP_Path])), QMessageBox::Ok, QMessageBox::Ok); QDir::toNativeSeparators(p_profile->Get(mach->properties[STR_PROP_Path])), QMessageBox::Ok, QMessageBox::Ok);
if (overview) overview->ReloadGraphs(); if (overview) overview->ReloadGraphs();
if (daily) { if (daily) {
@ -1812,13 +1812,13 @@ void MainWindow::purgeMachine(Machine * mach)
STR_MessageBox_Question, STR_MessageBox_Question,
tr("Machine data has been successfully purged.") + "\n\n" + tr("Machine data has been successfully purged.") + "\n\n" +
tr("Would you like to reimport from the backup folder?") + "\n\n" + tr("Would you like to reimport from the backup folder?") + "\n\n" +
QDir::toNativeSeparators(PROFILE.Get(mach->properties[STR_PROP_BackupPath])), QDir::toNativeSeparators(p_profile->Get(mach->properties[STR_PROP_BackupPath])),
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes) == QMessageBox::No) { QMessageBox::Yes) == QMessageBox::No) {
PROFILE.machlist.erase(PROFILE.machlist.find(mach->id())); p_profile->machlist.erase(p_profile->machlist.find(mach->id()));
delete mach; delete mach;
} else { } else {
importCPAP(PROFILE.Get(mach->properties[STR_PROP_BackupPath]),tr("Please wait, importing...")); importCPAP(p_profile->Get(mach->properties[STR_PROP_BackupPath]),tr("Please wait, importing..."));
if (overview) overview->ReloadGraphs(); if (overview) overview->ReloadGraphs();
if (daily) { if (daily) {
daily->clearLastDay(); // otherwise Daily will crash daily->clearLastDay(); // otherwise Daily will crash
@ -1826,7 +1826,7 @@ void MainWindow::purgeMachine(Machine * mach)
} }
} }
GenerateStatistics(); GenerateStatistics();
PROFILE.Save(); p_profile->Save();
} }
void MainWindow::keyPressEvent(QKeyEvent *event) void MainWindow::keyPressEvent(QKeyEvent *event)
@ -1942,13 +1942,13 @@ void MainWindow::reprocessEvents(bool restart)
void MainWindow::FreeSessions() void MainWindow::FreeSessions()
{ {
QDate first = PROFILE.FirstDay(); QDate first = p_profile->FirstDay();
QDate date = PROFILE.LastDay(); QDate date = p_profile->LastDay();
Day *day; Day *day;
QDate current = daily->getDate(); QDate current = daily->getDate();
do { do {
day = PROFILE.GetDay(date, MT_CPAP); day = p_profile->GetDay(date, MT_CPAP);
if (day) { if (day) {
if (date != current) { if (date != current) {
@ -1962,13 +1962,13 @@ void MainWindow::FreeSessions()
void MainWindow::doReprocessEvents() void MainWindow::doReprocessEvents()
{ {
if (PROFILE.countDays(MT_CPAP, PROFILE.FirstDay(), PROFILE.LastDay()) == 0) { if (p_profile->countDays(MT_CPAP, p_profile->FirstDay(), p_profile->LastDay()) == 0) {
return; return;
} }
m_inRecalculation = true; m_inRecalculation = true;
QDate first = PROFILE.FirstDay(); QDate first = p_profile->FirstDay();
QDate date = PROFILE.LastDay(); QDate date = p_profile->LastDay();
Session *sess; Session *sess;
Day *day; Day *day;
//FlowParser flowparser; //FlowParser flowparser;
@ -1980,10 +1980,10 @@ void MainWindow::doReprocessEvents()
int daycount = first.daysTo(date); int daycount = first.daysTo(date);
int idx = 0; int idx = 0;
QList<Machine *> machines = PROFILE.GetMachines(MT_CPAP); QList<Machine *> machines = p_profile->GetMachines(MT_CPAP);
// Disabling multithreaded save as it appears it's causing problems // Disabling multithreaded save as it appears it's causing problems
bool cache_sessions = false; //PROFILE.session->cacheSessions(); bool cache_sessions = false; //p_profile->session->cacheSessions();
if (cache_sessions) { // Use multithreaded save to handle reindexing.. (hogs memory like hell) if (cache_sessions) { // Use multithreaded save to handle reindexing.. (hogs memory like hell)
qstatus->setText(tr("Loading Event Data")); qstatus->setText(tr("Loading Event Data"));
@ -1999,7 +1999,7 @@ void MainWindow::doReprocessEvents()
bool isopen; bool isopen;
do { do {
day = PROFILE.GetDay(date, MT_CPAP); day = p_profile->GetDay(date, MT_CPAP);
if (day) { if (day) {
for (int i = 0; i < day->size(); i++) { for (int i = 0; i < day->size(); i++) {
@ -2144,7 +2144,7 @@ void MainWindow::on_actionChange_Language_triggered()
QSettings *settings = new QSettings(getDeveloperName(), getAppName()); QSettings *settings = new QSettings(getDeveloperName(), getAppName());
settings->remove("Settings/Language"); settings->remove("Settings/Language");
delete settings; delete settings;
PROFILE.Save(); p_profile->Save();
PREF.Save(); PREF.Save();
RestartApplication(true); RestartApplication(true);
@ -2152,7 +2152,7 @@ void MainWindow::on_actionChange_Language_triggered()
void MainWindow::on_actionChange_Data_Folder_triggered() void MainWindow::on_actionChange_Data_Folder_triggered()
{ {
PROFILE.Save(); p_profile->Save();
PREF.Save(); PREF.Save();
RestartApplication(false, true); RestartApplication(false, true);
} }
@ -2183,8 +2183,8 @@ void MainWindow::on_actionImport_Somnopose_Data_triggered()
void MainWindow::GenerateStatistics() void MainWindow::GenerateStatistics()
{ {
QDate first = PROFILE.FirstDay(); QDate first = p_profile->FirstDay();
QDate last = PROFILE.LastDay(); QDate last = p_profile->LastDay();
ui->statStartDate->setMinimumDate(first); ui->statStartDate->setMinimumDate(first);
ui->statStartDate->setMaximumDate(last); ui->statStartDate->setMaximumDate(last);
@ -2224,8 +2224,8 @@ void MainWindow::on_reportModeMonthly_clicked()
{ {
ui->statStartDate->setVisible(false); ui->statStartDate->setVisible(false);
ui->statEndDate->setVisible(false); ui->statEndDate->setVisible(false);
if (PROFILE.general->statReportMode() != 1) { if (p_profile->general->statReportMode() != 1) {
PROFILE.general->setStatReportMode(1); p_profile->general->setStatReportMode(1);
GenerateStatistics(); GenerateStatistics();
} }
} }
@ -2234,8 +2234,8 @@ void MainWindow::on_reportModeStandard_clicked()
{ {
ui->statStartDate->setVisible(false); ui->statStartDate->setVisible(false);
ui->statEndDate->setVisible(false); ui->statEndDate->setVisible(false);
if (PROFILE.general->statReportMode() != 0) { if (p_profile->general->statReportMode() != 0) {
PROFILE.general->setStatReportMode(0); p_profile->general->setStatReportMode(0);
GenerateStatistics(); GenerateStatistics();
} }
} }
@ -2245,8 +2245,8 @@ void MainWindow::on_reportModeRange_clicked()
{ {
ui->statStartDate->setVisible(true); ui->statStartDate->setVisible(true);
ui->statEndDate->setVisible(true); ui->statEndDate->setVisible(true);
if (PROFILE.general->statReportMode() != 2) { if (p_profile->general->statReportMode() != 2) {
PROFILE.general->setStatReportMode(2); p_profile->general->setStatReportMode(2);
GenerateStatistics(); GenerateStatistics();
} }
} }
@ -2256,7 +2256,7 @@ void MainWindow::on_actionPurgeCurrentDaysOximetry_triggered()
if (!getDaily()) if (!getDaily())
return; return;
QDate date = getDaily()->getDate(); QDate date = getDaily()->getDate();
Day * day = PROFILE.GetDay(date, MT_OXIMETER); Day * day = p_profile->GetDay(date, MT_OXIMETER);
if (day) { if (day) {
if (QMessageBox::question(this, STR_MessageBox_Warning, if (QMessageBox::question(this, STR_MessageBox_Warning,
tr("Are you sure you want to delete oximetry data for %1"). tr("Are you sure you want to delete oximetry data for %1").

View File

@ -106,7 +106,7 @@ Overview::Overview(QWidget *parent, gGraphView *shared) :
layout->layout(); layout->layout();
// TODO: Automate graph creation process // TODO: Automate graph creation process
ChannelID ahicode = PROFILE.general->calculateRDI() ? CPAP_RDI : CPAP_AHI; ChannelID ahicode = p_profile->general->calculateRDI() ? CPAP_RDI : CPAP_AHI;
if (ahicode == CPAP_RDI) { if (ahicode == CPAP_RDI) {
AHI = createGraph(STR_TR_RDI, tr("Respiratory\nDisturbance\nIndex")); AHI = createGraph(STR_TR_RDI, tr("Respiratory\nDisturbance\nIndex"));
@ -119,15 +119,15 @@ Overview::Overview(QWidget *parent, gGraphView *shared) :
FL = createGraph(STR_TR_FlowLimit, STR_TR_FlowLimit); FL = createGraph(STR_TR_FlowLimit, STR_TR_FlowLimit);
float percentile = PROFILE.general->prefCalcPercentile() / 100.0; float percentile = p_profile->general->prefCalcPercentile() / 100.0;
int mididx = PROFILE.general->prefCalcMiddle(); int mididx = p_profile->general->prefCalcMiddle();
SummaryType ST_mid; SummaryType ST_mid;
if (mididx == 0) { ST_mid = ST_PERC; } if (mididx == 0) { ST_mid = ST_PERC; }
if (mididx == 1) { ST_mid = ST_WAVG; } if (mididx == 1) { ST_mid = ST_WAVG; }
if (mididx == 2) { ST_mid = ST_AVG; } if (mididx == 2) { ST_mid = ST_AVG; }
SummaryType ST_max = PROFILE.general->prefCalcMax() ? ST_PERC : ST_MAX; SummaryType ST_max = p_profile->general->prefCalcMax() ? ST_PERC : ST_MAX;
const EventDataType maxperc = 0.995F; const EventDataType maxperc = 0.995F;
@ -224,7 +224,7 @@ Overview::Overview(QWidget *parent, gGraphView *shared) :
bc->addSlice(CPAP_Obstructive, COLOR_Obstructive, ST_CPH); bc->addSlice(CPAP_Obstructive, COLOR_Obstructive, ST_CPH);
bc->addSlice(CPAP_ClearAirway, COLOR_ClearAirway, ST_CPH); bc->addSlice(CPAP_ClearAirway, COLOR_ClearAirway, ST_CPH);
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
bc->addSlice(CPAP_RERA, COLOR_RERA, ST_CPH); bc->addSlice(CPAP_RERA, COLOR_RERA, ST_CPH);
} }
@ -325,7 +325,7 @@ void Overview::closeEvent(QCloseEvent *event)
gGraph *Overview::createGraph(QString name, QString units, YTickerType yttype) gGraph *Overview::createGraph(QString name, QString units, YTickerType yttype)
{ {
int default_height = PROFILE.appearance->graphHeight(); int default_height = p_profile->appearance->graphHeight();
gGraph *g = new gGraph(GraphView, name, units, default_height, 0); gGraph *g = new gGraph(GraphView, name, units, default_height, 0);
gYAxis *yt; gYAxis *yt;
@ -336,7 +336,7 @@ gGraph *Overview::createGraph(QString name, QString units, YTickerType yttype)
break; break;
case YT_Weight: case YT_Weight:
yt = new gYAxisWeight(PROFILE.general->unitSystem()); yt = new gYAxisWeight(p_profile->general->unitSystem());
break; break;
default: default:
@ -509,7 +509,7 @@ void Overview::ResetGraphLayout()
QDate s1=QDateTime::fromTime_t(st/1000L).date(); QDate s1=QDateTime::fromTime_t(st/1000L).date();
QDate s2=QDateTime::fromTime_t(et/1000L).date(); QDate s2=QDateTime::fromTime_t(et/1000L).date();
int len=PROFILE.countDays(MT_UNKNOWN,s1,s2); int len=p_profile->countDays(MT_UNKNOWN,s1,s2);
if (len>7) { if (len>7) {
if (QMessageBox::question(this, "Woah!", "Do you really want to print "+QString::number(len)+" days worth of Daily reports,\n from "+s1.toString(Qt::SystemLocaleShortDate)+" to "+s2.toString(Qt::SystemLocaleShortDate)+"?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::No) { if (QMessageBox::question(this, "Woah!", "Do you really want to print "+QString::number(len)+" days worth of Daily reports,\n from "+s1.toString(Qt::SystemLocaleShortDate)+" to "+s2.toString(Qt::SystemLocaleShortDate)+"?",QMessageBox::Yes,QMessageBox::No)==QMessageBox::No) {
return; return;
@ -535,10 +535,10 @@ void Overview::ResetGraphLayout()
void Overview::on_rangeCombo_activated(int index) void Overview::on_rangeCombo_activated(int index)
{ {
ui->dateStart->setMinimumDate(PROFILE.FirstDay()); ui->dateStart->setMinimumDate(p_profile->FirstDay());
ui->dateEnd->setMaximumDate(PROFILE.LastDay()); ui->dateEnd->setMaximumDate(p_profile->LastDay());
QDate end = PROFILE.LastDay(); QDate end = p_profile->LastDay();
QDate start; QDate start;
if (index == 8) { // Custom if (index == 8) { // Custom
@ -572,10 +572,10 @@ void Overview::on_rangeCombo_activated(int index)
} else if (index == 6) { } else if (index == 6) {
start = end.addYears(-1).addDays(1); start = end.addYears(-1).addDays(1);
} else if (index == 7) { // Everything } else if (index == 7) { // Everything
start = PROFILE.FirstDay(); start = p_profile->FirstDay();
} }
if (start < PROFILE.FirstDay()) { start = PROFILE.FirstDay(); } if (start < p_profile->FirstDay()) { start = p_profile->FirstDay(); }
setRange(start, end); setRange(start, end);
} }

View File

@ -205,7 +205,7 @@ void OximeterImport::on_directImportButton_clicked()
connect(oximodule, SIGNAL(updateProgress(int,int)), this, SLOT(doUpdateProgress(int,int))); connect(oximodule, SIGNAL(updateProgress(int,int)), this, SLOT(doUpdateProgress(int,int)));
oximodule->Open("import", p_profile); oximodule->Open("import");
// Wait to start import streaming.. // Wait to start import streaming..
while (!oximodule->isImporting() && !oximodule->isAborted()) { while (!oximodule->isImporting() && !oximodule->isAborted()) {
@ -287,7 +287,7 @@ void OximeterImport::on_fileImportButton_clicked()
oximodule = nullptr; oximodule = nullptr;
Q_FOREACH(SerialOximeter * loader, loaders) { Q_FOREACH(SerialOximeter * loader, loaders) {
if (loader->Open(filename,p_profile)) { if (loader->Open(filename)) {
success = true; success = true;
oximodule = loader; oximodule = loader;
break; break;
@ -330,7 +330,7 @@ void OximeterImport::on_liveImportButton_clicked()
return; return;
} }
Machine *mach = oximodule->CreateMachine(p_profile); Machine *mach = oximodule->CreateMachine();
connect(oximodule, SIGNAL(updatePlethy(QByteArray)), this, SLOT(on_updatePlethy(QByteArray))); connect(oximodule, SIGNAL(updatePlethy(QByteArray)), this, SLOT(on_updatePlethy(QByteArray)));
ui->liveConnectLabel->setText(tr("Live Oximetery Mode")); ui->liveConnectLabel->setText(tr("Live Oximetery Mode"));
@ -340,7 +340,7 @@ void OximeterImport::on_liveImportButton_clicked()
updateStatus(tr("If you can still read this after a few seconds, cancel and try again")); updateStatus(tr("If you can still read this after a few seconds, cancel and try again"));
ui->progressBar->hide(); ui->progressBar->hide();
liveView->update(); liveView->update();
oximodule->Open("live",p_profile); oximodule->Open("live");
ui->stopButton->setVisible(true); ui->stopButton->setVisible(true);
dummyday = new Day(mach); dummyday = new Day(mach);
@ -413,7 +413,7 @@ void OximeterImport::on_stopButton_clicked()
void OximeterImport::on_calendarWidget_clicked(const QDate &date) void OximeterImport::on_calendarWidget_clicked(const QDate &date)
{ {
if (ui->radioSyncCPAP->isChecked()) { if (ui->radioSyncCPAP->isChecked()) {
Day * day = PROFILE.GetGoodDay(date, MT_CPAP); Day * day = p_profile->GetGoodDay(date, MT_CPAP);
sessbar->clear(); sessbar->clear();
if (day) { if (day) {
@ -627,8 +627,8 @@ void OximeterImport::on_syncButton_clicked()
ui->syncButton->setVisible(false); ui->syncButton->setVisible(false);
ui->saveButton->setVisible(true); ui->saveButton->setVisible(true);
QDate first = PROFILE.FirstDay(); QDate first = p_profile->FirstDay();
QDate last = PROFILE.LastDay(); QDate last = p_profile->LastDay();
QDate oxidate = oximodule->startTime().date(); QDate oxidate = oximodule->startTime().date();
@ -676,7 +676,7 @@ void OximeterImport::on_saveButton_clicked()
// this can move to SerialOximeter class process function... // this can move to SerialOximeter class process function...
Machine * mach = oximodule->CreateMachine(p_profile); Machine * mach = oximodule->CreateMachine();
SessionID sid = ui->dateTimeEdit->dateTime().toUTC().toTime_t(); SessionID sid = ui->dateTimeEdit->dateTime().toUTC().toTime_t();
quint64 start = quint64(sid) * 1000L; quint64 start = quint64(sid) * 1000L;
@ -808,7 +808,7 @@ void OximeterImport::on_saveButton_clicked()
session->really_set_last(ti); session->really_set_last(ti);
session->SetChanged(true); session->SetChanged(true);
mach->AddSession(session, p_profile); mach->AddSession(session);
mach->Save(); mach->Save();
mainwin->getDaily()->LoadDate(mainwin->getDaily()->getDate()); mainwin->getDaily()->LoadDate(mainwin->getDaily()->getDate());

View File

@ -374,7 +374,7 @@ bool PreferencesDialog::Save()
} }
if (recalc_events) { if (recalc_events) {
if (PROFILE.countDays(MT_CPAP, PROFILE.FirstDay(), PROFILE.LastDay()) > 0) { if (p_profile->countDays(MT_CPAP, p_profile->FirstDay(), p_profile->LastDay()) > 0) {
if (QMessageBox::question(this, tr("Data Reindex Required"), if (QMessageBox::question(this, tr("Data Reindex Required"),
tr("A data reindexing proceedure is required to apply these changes. This operation may take a couple of minutes to complete.\n\nAre you sure you want to make these changes?"), tr("A data reindexing proceedure is required to apply these changes. This operation may take a couple of minutes to complete.\n\nAre you sure you want to make these changes?"),
QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) {
@ -542,7 +542,7 @@ bool PreferencesDialog::Save()
//qDebug() << "TODO: Save channels.xml to update channel data"; //qDebug() << "TODO: Save channels.xml to update channel data";
PREF.Save(); PREF.Save();
PROFILE.Save(); p_profile->Save();
if (recalc_events) { if (recalc_events) {
@ -857,7 +857,7 @@ void PreferencesDialog::on_maskTypeCombo_activated(int index)
void PreferencesDialog::on_createSDBackups_toggled(bool checked) void PreferencesDialog::on_createSDBackups_toggled(bool checked)
{ {
if (profile->session->backupCardData() && !checked) { if (profile->session->backupCardData() && !checked) {
QList<Machine *> mach = PROFILE.GetMachines(MT_CPAP); QList<Machine *> mach = p_profile->GetMachines(MT_CPAP);
bool haveS9 = false; bool haveS9 = false;
for (int i = 0; i < mach.size(); i++) { for (int i = 0; i < mach.size(); i++) {

View File

@ -205,7 +205,7 @@ void ProfileSelect::deleteProfile()
if (!profile) { if (!profile) {
QMessageBox::warning(this, STR_MessageBox_Error, QMessageBox::warning(this, STR_MessageBox_Error,
QString(tr("Could not open profile.. You will need to delete this profile directory manually")+ QString(tr("Could not open profile.. You will need to delete this profile directory manually")+
"\n\n"+tr("You will find it under the following location:")+"\n\n%1").arg(QDir::toNativeSeparators(GetAppRoot() + "/Profiles/" + PROFILE.user->userName())), QMessageBox::Ok); "\n\n"+tr("You will find it under the following location:")+"\n\n%1").arg(QDir::toNativeSeparators(GetAppRoot() + "/Profiles/" + p_profile->user->userName())), QMessageBox::Ok);
return; return;
} }
bool reallydelete = false; bool reallydelete = false;

View File

@ -43,7 +43,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
return; return;
} }
QString username = PROFILE.Get(QString("_{") + QString(STR_UI_UserName) + "}_"); QString username = p_profile->Get(QString("_{") + QString(STR_UI_UserName) + "}_");
bool print_bookmarks = false; bool print_bookmarks = false;
@ -66,7 +66,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
QPrinter *printer; QPrinter *printer;
bool aa_setting = PROFILE.appearance->antiAliasing(); bool aa_setting = p_profile->appearance->antiAliasing();
bool force_antialiasing = aa_setting; bool force_antialiasing = aa_setting;
@ -141,18 +141,18 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
int maxy = 0; int maxy = 0;
if (!PROFILE.user->firstName().isEmpty()) { if (!p_profile->user->firstName().isEmpty()) {
QString userinfo = STR_TR_Name + QString(":\t %1, %2\n").arg(PROFILE.user->lastName()).arg( QString userinfo = STR_TR_Name + QString(":\t %1, %2\n").arg(p_profile->user->lastName()).arg(
PROFILE.user->firstName()); p_profile->user->firstName());
userinfo += STR_TR_DOB + QString(":\t%1\n").arg(PROFILE.user->DOB().toString( userinfo += STR_TR_DOB + QString(":\t%1\n").arg(p_profile->user->DOB().toString(
Qt::SystemLocaleShortDate)); Qt::SystemLocaleShortDate));
if (!PROFILE.doctor->patientID().isEmpty()) { userinfo += STR_TR_PatientID + QString(":\t%1\n").arg(PROFILE.doctor->patientID()); } if (!p_profile->doctor->patientID().isEmpty()) { userinfo += STR_TR_PatientID + QString(":\t%1\n").arg(p_profile->doctor->patientID()); }
userinfo += STR_TR_Phone + QString(":\t%1\n").arg(PROFILE.user->phone()); userinfo += STR_TR_Phone + QString(":\t%1\n").arg(p_profile->user->phone());
userinfo += STR_TR_Email + QString(":\t%1\n").arg(PROFILE.user->email()); userinfo += STR_TR_Email + QString(":\t%1\n").arg(p_profile->user->email());
if (!PROFILE.user->address().isEmpty()) { userinfo += "\n" + STR_TR_Address + QString(":\n%1").arg(PROFILE.user->address()); } if (!p_profile->user->address().isEmpty()) { userinfo += "\n" + STR_TR_Address + QString(":\n%1").arg(p_profile->user->address()); }
QRectF bounds = painter.boundingRect(QRectF(0, top, virt_width, 0), userinfo, QRectF bounds = painter.boundingRect(QRectF(0, top, virt_width, 0), userinfo,
QTextOption(Qt::AlignLeft | Qt::AlignTop)); QTextOption(Qt::AlignLeft | Qt::AlignTop));
@ -166,8 +166,8 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
int graph_slots = 0; int graph_slots = 0;
if (name == STR_TR_Daily) { if (name == STR_TR_Daily) {
cpap = PROFILE.GetGoodDay(date, MT_CPAP); cpap = p_profile->GetGoodDay(date, MT_CPAP);
oxi = PROFILE.GetGoodDay(date, MT_OXIMETER); oxi = p_profile->GetGoodDay(date, MT_OXIMETER);
QString cpapinfo = date.toString(Qt::SystemLocaleLongDate) + "\n\n"; QString cpapinfo = date.toString(Qt::SystemLocaleLongDate) + "\n\n";
if (cpap) { if (cpap) {
@ -227,7 +227,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
float ahi = (cpap->count(CPAP_Obstructive) + cpap->count(CPAP_Hypopnea) + cpap->count( float ahi = (cpap->count(CPAP_Obstructive) + cpap->count(CPAP_Hypopnea) + cpap->count(
CPAP_ClearAirway) + cpap->count(CPAP_Apnea)); CPAP_ClearAirway) + cpap->count(CPAP_Apnea));
if (PROFILE.general->calculateRDI()) { ahi += cpap->count(CPAP_RERA); } if (p_profile->general->calculateRDI()) { ahi += cpap->count(CPAP_RERA); }
ahi /= cpap->hours(); ahi /= cpap->hours();
float csr = (100.0 / cpap->hours()) * (cpap->sum(CPAP_CSR) / 3600.0); float csr = (100.0 / cpap->hours()) * (cpap->sum(CPAP_CSR) / 3600.0);
@ -251,7 +251,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
QString stats; QString stats;
painter.setFont(medium_font); painter.setFont(medium_font);
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
stats = QObject::tr("RDI\t%1\n").arg(ahi, 0, 'f', 2); stats = QObject::tr("RDI\t%1\n").arg(ahi, 0, 'f', 2);
} else { } else {
stats = QObject::tr("AHI\t%1\n").arg(ahi, 0, 'f', 2); stats = QObject::tr("AHI\t%1\n").arg(ahi, 0, 'f', 2);
@ -585,7 +585,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
top += bounds.height(); top += bounds.height();
} else { top += normal_height / 2; } } else { top += normal_height / 2; }
PROFILE.appearance->setAntiAliasing(force_antialiasing); p_profile->appearance->setAntiAliasing(force_antialiasing);
int tmb = g->m_marginbottom; int tmb = g->m_marginbottom;
g->m_marginbottom = 0; g->m_marginbottom = 0;
@ -603,7 +603,7 @@ void Report::PrintReport(gGraphView *gv, QString name, QDate date)
//g->showTitle(true); //g->showTitle(true);
//painter.endNativePainting(); //painter.endNativePainting();
g->m_marginbottom = tmb; g->m_marginbottom = tmb;
PROFILE.appearance->setAntiAliasing(aa_setting); p_profile->appearance->setAntiAliasing(aa_setting);
if (!pm.isNull()) { if (!pm.isNull()) {

View File

@ -1 +1 @@
1 2

View File

@ -106,25 +106,25 @@ Statistics::Statistics(QObject *parent) :
QString htmlHeader() QString htmlHeader()
{ {
QString address = PROFILE.user->address(); QString address = p_profile->user->address();
address.replace("\n", "<br/>"); address.replace("\n", "<br/>");
// "a:link,a:visited { color: '#000020'; text-decoration: none; font-weight: bold;}" // "a:link,a:visited { color: '#000020'; text-decoration: none; font-weight: bold;}"
// "a:hover { background-color: inherit; color: red; text-decoration:none; font-weight: bold; }" // "a:hover { background-color: inherit; color: red; text-decoration:none; font-weight: bold; }"
QString userinfo; QString userinfo;
if (!PROFILE.user->firstName().isEmpty()) { if (!p_profile->user->firstName().isEmpty()) {
userinfo = QString(QObject::tr("Name: %1, %2")).arg(PROFILE.user->lastName()).arg(PROFILE.user->firstName()) + "<br/>"; userinfo = QString(QObject::tr("Name: %1, %2")).arg(p_profile->user->lastName()).arg(p_profile->user->firstName()) + "<br/>";
if (!PROFILE.user->DOB().isNull()) { if (!p_profile->user->DOB().isNull()) {
userinfo += QString(QObject::tr("DOB: %1")).arg(PROFILE.user->DOB().toString()) + "<br/>"; userinfo += QString(QObject::tr("DOB: %1")).arg(p_profile->user->DOB().toString()) + "<br/>";
} }
if (!PROFILE.user->phone().isEmpty()) { if (!p_profile->user->phone().isEmpty()) {
userinfo += QString(QObject::tr("Phone: %1")).arg(PROFILE.user->phone()) + "<br/>"; userinfo += QString(QObject::tr("Phone: %1")).arg(p_profile->user->phone()) + "<br/>";
} }
if (!PROFILE.user->email().isEmpty()) { if (!p_profile->user->email().isEmpty()) {
userinfo += QString(QObject::tr("Email: %1")).arg(PROFILE.user->email()) + "<br/><br/>"; userinfo += QString(QObject::tr("Email: %1")).arg(p_profile->user->email()) + "<br/><br/>";
} }
if (!PROFILE.user->address().isEmpty()) { if (!p_profile->user->address().isEmpty()) {
userinfo += QObject::tr("Address:")+"<br/>"+address; userinfo += QObject::tr("Address:")+"<br/>"+address;
} }
} }
@ -197,7 +197,7 @@ EventDataType calcAHI(QDate start, QDate end)
+ p_profile->calcCount(CPAP_ClearAirway, MT_CPAP, start, end) + p_profile->calcCount(CPAP_ClearAirway, MT_CPAP, start, end)
+ p_profile->calcCount(CPAP_Apnea, MT_CPAP, start, end)); + p_profile->calcCount(CPAP_Apnea, MT_CPAP, start, end));
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
val += p_profile->calcCount(CPAP_RERA, MT_CPAP, start, end); val += p_profile->calcCount(CPAP_RERA, MT_CPAP, start, end);
} }
@ -528,8 +528,8 @@ QString Statistics::GenerateHTML()
if (cpap6month < firstcpap) { cpap6month = firstcpap; } if (cpap6month < firstcpap) { cpap6month = firstcpap; }
if (cpapyear < firstcpap) { cpapyear = firstcpap; } if (cpapyear < firstcpap) { cpapyear = firstcpap; }
QList<Machine *> cpap_machines = PROFILE.GetMachines(MT_CPAP); QList<Machine *> cpap_machines = p_profile->GetMachines(MT_CPAP);
QList<Machine *> oximeters = PROFILE.GetMachines(MT_OXIMETER); QList<Machine *> oximeters = p_profile->GetMachines(MT_OXIMETER);
QList<Machine *> mach; QList<Machine *> mach;
mach.append(cpap_machines); mach.append(cpap_machines);
mach.append(oximeters); mach.append(oximeters);
@ -545,14 +545,14 @@ QString Statistics::GenerateHTML()
return html; return html;
} }
int cpapdays = PROFILE.countDays(MT_CPAP, firstcpap, lastcpap); int cpapdays = p_profile->countDays(MT_CPAP, firstcpap, lastcpap);
CPAPMode cpapmode = (CPAPMode)(int)p_profile->calcSettingsMax(CPAP_Mode, MT_CPAP, firstcpap, CPAPMode cpapmode = (CPAPMode)(int)p_profile->calcSettingsMax(CPAP_Mode, MT_CPAP, firstcpap,
lastcpap); lastcpap);
float percentile = PROFILE.general->prefCalcPercentile() / 100.0; float percentile = p_profile->general->prefCalcPercentile() / 100.0;
// int mididx=PROFILE.general->prefCalcMiddle(); // int mididx=p_profile->general->prefCalcMiddle();
// SummaryType ST_mid; // SummaryType ST_mid;
// if (mididx==0) ST_mid=ST_PERC; // if (mididx==0) ST_mid=ST_PERC;
// if (mididx==1) ST_mid=ST_WAVG; // if (mididx==1) ST_mid=ST_WAVG;
@ -560,7 +560,7 @@ QString Statistics::GenerateHTML()
QString ahitxt; QString ahitxt;
if (PROFILE.general->calculateRDI()) { if (p_profile->general->calculateRDI()) {
ahitxt = STR_TR_RDI; ahitxt = STR_TR_RDI;
} else { } else {
ahitxt = STR_TR_AHI; ahitxt = STR_TR_AHI;
@ -572,7 +572,7 @@ QString Statistics::GenerateHTML()
int number_periods = 0; int number_periods = 0;
if (p_profile->general->statReportMode() == 1) { if (p_profile->general->statReportMode() == 1) {
number_periods = PROFILE.FirstDay().daysTo(PROFILE.LastDay()) / 30; number_periods = p_profile->FirstDay().daysTo(p_profile->LastDay()) / 30;
if (number_periods > 12) { if (number_periods > 12) {
number_periods = 12; number_periods = 12;
} }
@ -638,7 +638,7 @@ QString Statistics::GenerateHTML()
} }
} }
int days = PROFILE.countDays(row.type, first, last); int days = p_profile->countDays(row.type, first, last);
skipsection = (days == 0); skipsection = (days == 0);
if (days > 0) { if (days > 0) {
html+=QString("<tr bgcolor='%1'><th colspan=%2 align=center><font size=+2>%3</font></th></tr>\n"). html+=QString("<tr bgcolor='%1'><th colspan=%2 align=center><font size=+2>%3</font></th></tr>\n").
@ -693,7 +693,7 @@ QString Statistics::GenerateHTML()
continue; continue;
} else { } else {
ChannelID id = schema::channel[row.src].id(); ChannelID id = schema::channel[row.src].id();
if ((id == NoChannel) || (!PROFILE.hasChannel(id))) { if ((id == NoChannel) || (!p_profile->hasChannel(id))) {
continue; continue;
} }
name = calcnames[row.calc].arg(schema::channel[id].fullname()); name = calcnames[row.calc].arg(schema::channel[id].fullname());
@ -743,21 +743,21 @@ QString Statistics::GenerateHTML()
int compliant = 0; int compliant = 0;
do { do {
day = PROFILE.GetGoodDay(date, MT_CPAP); day = p_profile->GetGoodDay(date, MT_CPAP);
if (day) { if (day) {
lastchanged = false; lastchanged = false;
hours = day->hours(); hours = day->hours();
if (hours > PROFILE.cpap->complianceHours()) { if (hours > p_profile->cpap->complianceHours()) {
compliant++; compliant++;
} }
EventDataType ahi = day->count(CPAP_Obstructive) + day->count(CPAP_Hypopnea) + day->count( EventDataType ahi = day->count(CPAP_Obstructive) + day->count(CPAP_Hypopnea) + day->count(
CPAP_Apnea) + day->count(CPAP_ClearAirway); CPAP_Apnea) + day->count(CPAP_ClearAirway);
if (PROFILE.general->calculateRDI()) { ahi += day->count(CPAP_RERA); } if (p_profile->general->calculateRDI()) { ahi += day->count(CPAP_RERA); }
ahi /= hours; ahi /= hours;
AHI.push_back(UsageData(date, ahi, hours)); AHI.push_back(UsageData(date, ahi, hours));
@ -807,7 +807,7 @@ QString Statistics::GenerateHTML()
|| (maxipap != cmaxipap) || (mach != lastmach) || (prelset != lastprelset)) { || (maxipap != cmaxipap) || (mach != lastmach) || (prelset != lastprelset)) {
if ((cmode != MODE_UNKNOWN) && (lastmach != nullptr)) { if ((cmode != MODE_UNKNOWN) && (lastmach != nullptr)) {
first = date.addDays(1); first = date.addDays(1);
int days = PROFILE.countDays(MT_CPAP, first, last); int days = p_profile->countDays(MT_CPAP, first, last);
RXChange rx; RXChange rx;
rx.first = first; rx.first = first;
rx.last = last; rx.last = last;
@ -865,7 +865,7 @@ QString Statistics::GenerateHTML()
if (!lastchanged && (mach != nullptr)) { if (!lastchanged && (mach != nullptr)) {
// last=date.addDays(1); // last=date.addDays(1);
first = firstcpap; first = firstcpap;
int days = PROFILE.countDays(MT_CPAP, first, last); int days = p_profile->countDays(MT_CPAP, first, last);
RXChange rx; RXChange rx;
rx.first = first; rx.first = first;
rx.last = last; rx.last = last;
@ -927,7 +927,7 @@ QString Statistics::GenerateHTML()
recbox += QString("<tr><td>%1</td><td align=right>%2</td></tr>").arg(tr("Total Days")).arg( recbox += QString("<tr><td>%1</td><td align=right>%2</td></tr>").arg(tr("Total Days")).arg(
numdays); numdays);
if (PROFILE.cpap->showComplianceInfo()) { if (p_profile->cpap->showComplianceInfo()) {
recbox += QString("<tr><td>%1</td><td align=right>%2</td></tr>").arg(tr("Compliant Days")).arg( recbox += QString("<tr><td>%1</td><td align=right>%2</td></tr>").arg(tr("Compliant Days")).arg(
compliant); compliant);
} }
@ -979,7 +979,7 @@ QString Statistics::GenerateHTML()
tmpRX[0]->highlight = 4; // worst tmpRX[0]->highlight = 4; // worst
int ls = tmpRX.size() - 1; int ls = tmpRX.size() - 1;
tmpRX[ls]->highlight = 1; //best tmpRX[ls]->highlight = 1; //best
CPAPMode mode = (CPAPMode)(int)PROFILE.calcSettingsMax(CPAP_Mode, MT_CPAP, tmpRX[ls]->first, CPAPMode mode = (CPAPMode)(int)p_profile->calcSettingsMax(CPAP_Mode, MT_CPAP, tmpRX[ls]->first,
tmpRX[ls]->last); tmpRX[ls]->last);
@ -1028,7 +1028,7 @@ QString Statistics::GenerateHTML()
recbox += QString("<tr><td colspan=2>&nbsp;</td></tr>"); recbox += QString("<tr><td colspan=2>&nbsp;</td></tr>");
mode = (CPAPMode)(int)PROFILE.calcSettingsMax(CPAP_Mode, MT_CPAP, tmpRX[0]->first, tmpRX[0]->last); mode = (CPAPMode)(int)p_profile->calcSettingsMax(CPAP_Mode, MT_CPAP, tmpRX[0]->first, tmpRX[0]->last);
if (mode < MODE_APAP) { // is CPAP? if (mode < MODE_APAP) { // is CPAP?
minstr = STR_TR_Pressure; minstr = STR_TR_Pressure;
@ -1093,7 +1093,7 @@ QString Statistics::GenerateHTML()
hdrlist.push_back(tr("Days")); hdrlist.push_back(tr("Days"));
hdrlist.push_back(ahitxt); hdrlist.push_back(ahitxt);
hdrlist.push_back(STR_TR_FL); hdrlist.push_back(STR_TR_FL);
if (PROFILE.hasChannel(CPAP_SensAwake)) { if (p_profile->hasChannel(CPAP_SensAwake)) {
hdrlist.push_back(STR_TR_SA); hdrlist.push_back(STR_TR_SA);
} }
hdrlist.push_back(STR_TR_Machine); hdrlist.push_back(STR_TR_Machine);
@ -1233,7 +1233,7 @@ QString Statistics::GenerateHTML()
html += QString("<td>%1</td>").arg(rx.ahi, 0, 'f', decimals); html += QString("<td>%1</td>").arg(rx.ahi, 0, 'f', decimals);
html += QString("<td>%1</td>").arg(rx.fl, 0, 'f', decimals); // Not the best way to do this.. Todo: Add an extra field for data.. html += QString("<td>%1</td>").arg(rx.fl, 0, 'f', decimals); // Not the best way to do this.. Todo: Add an extra field for data..
if (PROFILE.hasChannel(CPAP_SensAwake)) { if (p_profile->hasChannel(CPAP_SensAwake)) {
html += QString("<td>%1</td>").arg(calcSA(rx.first, rx.last), 0, 'f', decimals); html += QString("<td>%1</td>").arg(calcSA(rx.first, rx.last), 0, 'f', decimals);
} }
html += QString("<td>%1</td>").arg(rx.machine->GetClass()); html += QString("<td>%1</td>").arg(rx.machine->GetClass());
@ -1298,7 +1298,7 @@ QString StatisticsRow::value(QDate start, QDate end)
{ {
const int decimals=2; const int decimals=2;
QString value; QString value;
float days = PROFILE.countDays(type, start, end); float days = p_profile->countDays(type, start, end);
// Handle special data sources first // Handle special data sources first
if (calc == SC_AHI) { if (calc == SC_AHI) {
@ -1336,8 +1336,8 @@ QString StatisticsRow::value(QDate start, QDate end)
value = QString("%1").arg(p_profile->calcMax(code, type, start, end), 0, 'f', decimals); value = QString("%1").arg(p_profile->calcMax(code, type, start, end), 0, 'f', decimals);
break; break;
case SC_CPH: case SC_CPH:
value = QString("%1").arg(PROFILE.calcCount(code, type, start, end) value = QString("%1").arg(p_profile->calcCount(code, type, start, end)
/ PROFILE.calcHours(type, start, end), 0, 'f', decimals); / p_profile->calcHours(type, start, end), 0, 'f', decimals);
break; break;
case SC_SPH: case SC_SPH:
value = QString("%1%").arg(100.0 / p_profile->calcHours(type, start, end) value = QString("%1%").arg(100.0 / p_profile->calcHours(type, start, end)