From ce2ac29cd0d808ff3a4a6c67af20fd0796df4ad7 Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 8 Aug 2014 06:27:23 +1000 Subject: [PATCH] More color and flag consistency cleanups --- sleepyhead/Graphs/gFlagsLine.cpp | 90 +++++++------- sleepyhead/Graphs/gGraphView.cpp | 5 + sleepyhead/Graphs/gLineChart.cpp | 64 +++++++--- sleepyhead/SleepLib/day.cpp | 21 ++++ sleepyhead/SleepLib/day.h | 3 + .../SleepLib/loader_plugins/prs1_loader.cpp | 30 ++--- sleepyhead/SleepLib/machine.cpp | 4 +- sleepyhead/SleepLib/machine.h | 2 +- sleepyhead/SleepLib/profiles.h | 4 + sleepyhead/SleepLib/schema.cpp | 4 +- sleepyhead/SleepLib/schema.h | 1 + sleepyhead/daily.cpp | 114 +++++++++--------- sleepyhead/preferencesdialog.cpp | 6 + sleepyhead/preferencesdialog.ui | 20 ++- 14 files changed, 217 insertions(+), 151 deletions(-) diff --git a/sleepyhead/Graphs/gFlagsLine.cpp b/sleepyhead/Graphs/gFlagsLine.cpp index 1540f8e2..20de6464 100644 --- a/sleepyhead/Graphs/gFlagsLine.cpp +++ b/sleepyhead/Graphs/gFlagsLine.cpp @@ -78,11 +78,13 @@ void gFlagsGroup::SetDay(Day *d) schema::channel[CPAP_VSnore].setOrder(7); schema::channel[CPAP_VSnore2].setOrder(8); schema::channel[CPAP_ExP].setOrder(6); + schema::channel[CPAP_UserFlag1].setOrder(256); + schema::channel[CPAP_UserFlag2].setOrder(257); - availableChans.clear(); - availableChans.append(d->machine->availableChannels(schema::FLAG)); - availableChans.append(d->machine->availableChannels(schema::SPAN)); + quint32 z = schema::FLAG | schema::SPAN; + if (p_profile->general->showUnknownFlags()) z |= schema::UNKNOWN; + availableChans = d->getSortedMachineChannels(z); m_rebuild_cpap = (availableChans.size() == 0); @@ -99,33 +101,22 @@ void gFlagsGroup::SetDay(Day *d) schema::Channel * chan = &schema::channel[code]; if (chan->type() == schema::FLAG) { - chans[code] = chan; + availableChans.push_back(code); } else if (chan->type() == schema::MINOR_FLAG) { - // chans[code] = chan; + availableChans.push_back(code); } else if (chan->type() == schema::SPAN) { - chans[code] = chan; + availableChans.push_back(code); + } else if (chan->type() == schema::UNKNOWN) { + availableChans.push_back(code); } } } availableChans = chans.keys(); } - QMultiMap order; - + lvisible.clear(); for (int i=0; i < availableChans.size(); ++i) { ChannelID code = availableChans.at(i); - order.insert(schema::channel[code].order(), code); - } - - QMultiMap::iterator it; - - for (int i=0;i maxx) { - break; - } - - x1 = (X - minx) * xmult + left; - - if (!hover && QRect(x1-3, bartop-2, 6, bottom-bartop+4).contains(w.graphView()->currentMousePos())) { - hover = true; - painter.setPen(QPen(Qt::red,1)); - - painter.drawRect(x1-2, bartop-2, 4, bottom-bartop+4); - int x,y; - QString lab = QString("%1 (%2)").arg(schema::channel[m_code].fullname()).arg(*dptr); - GetTextExtent(lab, x, y); - - w.ToolTip(lab, x1 - 10, bartop + (3 * w.printScaleY()), TT_AlignRight, p_profile->general->tooltipTimeout()); - } - - vlines.append(QLine(x1, bartop, x1, bottom)); - } - } else if (chan.type() == schema::SPAN) { + if (chan.type() == schema::SPAN) { /////////////////////////////////////////////////////////////////////////// // Draw Event Flag Spans /////////////////////////////////////////////////////////////////////////// @@ -416,6 +379,35 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion ®ion) } } + + } else { //if (chan.type() == schema::FLAG) { + /////////////////////////////////////////////////////////////////////////// + // Draw Event Flag Bars + /////////////////////////////////////////////////////////////////////////// + + for (int i = 0; i < np; i++) { + X = start + *tptr++; + + if (X > maxx) { + break; + } + + x1 = (X - minx) * xmult + left; + + if (!hover && QRect(x1-3, bartop-2, 6, bottom-bartop+4).contains(w.graphView()->currentMousePos())) { + hover = true; + painter.setPen(QPen(Qt::red,1)); + + painter.drawRect(x1-2, bartop-2, 4, bottom-bartop+4); + int x,y; + QString lab = QString("%1 (%2)").arg(schema::channel[m_code].fullname()).arg(*dptr); + GetTextExtent(lab, x, y); + + w.ToolTip(lab, x1 - 10, bartop + (3 * w.printScaleY()), TT_AlignRight, p_profile->general->tooltipTimeout()); + } + + vlines.append(QLine(x1, bartop, x1, bottom)); + } } } } diff --git a/sleepyhead/Graphs/gGraphView.cpp b/sleepyhead/Graphs/gGraphView.cpp index d772a838..f8f95756 100644 --- a/sleepyhead/Graphs/gGraphView.cpp +++ b/sleepyhead/Graphs/gGraphView.cpp @@ -405,6 +405,11 @@ void gGraphView::dumpInfo() case schema::WAVEFORM: text = "WAVEFORM: "; break; + case schema::UNKNOWN: + text = "UNKNOWN: "; + break; + default: + break; } QStringList str; for (int i=0; i< lit.value().size(); ++i) { diff --git a/sleepyhead/Graphs/gLineChart.cpp b/sleepyhead/Graphs/gLineChart.cpp index c7cd39ac..8ebe8102 100644 --- a/sleepyhead/Graphs/gLineChart.cpp +++ b/sleepyhead/Graphs/gLineChart.cpp @@ -158,31 +158,55 @@ skipcheck: flags.clear(); - for (int i=0; i< m_day->size(); ++i) { - Session * sess = m_day->sessions.at(i); - QHash >::iterator it; - for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) { - ChannelID code = it.key(); + quint32 z = schema::FLAG | schema::MINOR_FLAG | schema::SPAN; + if (p_profile->general->showUnknownFlags()) z |= schema::UNKNOWN; + QList available = m_day->getSortedMachineChannels(z); - if (flags.contains(code)) continue; + for (int i=0; i < available.size(); ++i) { + ChannelID code = available.at(i); - schema::Channel * chan = &schema::channel[code]; - gLineOverlayBar * lob = nullptr; + schema::Channel * chan = &schema::channel[code]; + gLineOverlayBar * lob = nullptr; - if (chan->type() == schema::FLAG) { - lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Bar); - } else if (chan->type() == schema::MINOR_FLAG) { - lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Dot); - } else if (chan->type() == schema::SPAN) { - lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span); - } - if (lob != nullptr) { - lob->setOverlayDisplayType((m_codes[0] == CPAP_FlowRate) ? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom); - lob->SetDay(m_day); - flags[code] = lob; - } + if (chan->type() == schema::FLAG) { + lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Bar); + } else if ((chan->type() == schema::MINOR_FLAG) || (chan->type() == schema::UNKNOWN)) { + lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Dot); + } else if (chan->type() == schema::SPAN) { + lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span); + } + if (lob != nullptr) { + lob->setOverlayDisplayType((m_codes[0] == CPAP_FlowRate) ? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom); + lob->SetDay(m_day); + flags[code] = lob; } } + +// for (int i=0; i< m_day->size(); ++i) { +// Session * sess = m_day->sessions.at(i); +// QHash >::iterator it; +// for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) { +// ChannelID code = it.key(); + +// if (flags.contains(code)) continue; + +// schema::Channel * chan = &schema::channel[code]; +// gLineOverlayBar * lob = nullptr; + +// if (chan->type() == schema::FLAG) { +// lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Bar); +// } else if (chan->type() == schema::MINOR_FLAG) { +// lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Dot); +// } else if (chan->type() == schema::SPAN) { +// lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span); +// } +// if (lob != nullptr) { +// lob->setOverlayDisplayType((m_codes[0] == CPAP_FlowRate) ? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom); +// lob->SetDay(m_day); +// flags[code] = lob; +// } +// } +// } } EventDataType gLineChart::Miny() { diff --git a/sleepyhead/SleepLib/day.cpp b/sleepyhead/SleepLib/day.cpp index 185846ae..7bad776c 100644 --- a/sleepyhead/SleepLib/day.cpp +++ b/sleepyhead/SleepLib/day.cpp @@ -900,6 +900,27 @@ void Day::CloseEvents() } } +QList Day::getSortedMachineChannels(quint32 chantype) +{ + QList available = machine->availableChannels(chantype); + + QMultiMap order; + + for (int i=0; i < available.size(); ++i) { + ChannelID code = available.at(i); + order.insert(schema::channel[code].order(), code); + } + + QMultiMap::iterator it; + + QList channels; + for (it = order.begin(); it != order.end(); ++it) { + ChannelID code = it.value(); + channels.append(code); + } + return channels; +} + qint64 Day::first() { qint64 date = 0; diff --git a/sleepyhead/SleepLib/day.h b/sleepyhead/SleepLib/day.h index da79e891..aaea681b 100644 --- a/sleepyhead/SleepLib/day.h +++ b/sleepyhead/SleepLib/day.h @@ -176,8 +176,11 @@ class Day //! \brief Returns true if this day contains the supplied settings Channel id bool settingExists(ChannelID id); + //! \brief Removes a session from this day bool removeSession(Session *sess); + //! \brief Returns a list of channels of supplied types, according to channel orders + QList getSortedMachineChannels(quint32 chantype); // Some ugly CPAP specific stuff QString getCPAPMode(); diff --git a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp index a951c393..c61a2b73 100644 --- a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp @@ -874,7 +874,7 @@ bool PRS1Import::ParseF0Events() EventList *FL = session->AddEventList(CPAP_FlowLimit, EVL_Event); EventList *VS = session->AddEventList(CPAP_VSnore, EVL_Event); EventList *VS2 = session->AddEventList(CPAP_VSnore2, EVL_Event); - EventList *T1 = session->AddEventList(CPAP_Test1, EVL_Event, 0.1); + //EventList *T1 = session->AddEventList(CPAP_Test1, EVL_Event, 0.1); Code[12] = session->AddEventList(PRS1_0B, EVL_Event); Code[17] = session->AddEventList(PRS1_0E, EVL_Event); @@ -2137,7 +2137,7 @@ void PRS1Loader::initChannels() QString unknownname=QObject::tr("PRS1_%1"); QString unknownshort=QObject::tr("PRS1_%1"); - channel.add(GRP_CPAP, new Channel(PRS1_00 = 0x1150, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_00 = 0x1150, UNKNOWN, SESSION, "PRS1_00", QString(unknownname).arg(0,2,16,QChar('0')), QString(unknowndesc).arg(0,2,16,QChar('0')), @@ -2145,7 +2145,7 @@ void PRS1Loader::initChannels() STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_01 = 0x1151, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_01 = 0x1151, UNKNOWN, SESSION, "PRS1_01", QString(unknownname).arg(1,2,16,QChar('0')), QString(unknowndesc).arg(1,2,16,QChar('0')), @@ -2153,7 +2153,7 @@ void PRS1Loader::initChannels() STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_08 = 0x1152, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_08 = 0x1152, UNKNOWN, SESSION, "PRS1_08", QString(unknownname).arg(8,2,16,QChar('0')), QString(unknowndesc).arg(8,2,16,QChar('0')), @@ -2161,41 +2161,41 @@ void PRS1Loader::initChannels() STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_0A = 0x1154, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_0A = 0x1154, UNKNOWN, SESSION, "PRS1_0A", QString(unknownname).arg(0xa,2,16,QChar('0')), QString(unknowndesc).arg(0xa,2,16,QChar('0')), QString(unknownshort).arg(0xa,2,16,QChar('0')), STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_0B = 0x1155, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_0B = 0x1155, UNKNOWN, SESSION, "PRS1_0B", QString(unknownname).arg(0xb,2,16,QChar('0')), QString(unknowndesc).arg(0xb,2,16,QChar('0')), QString(unknownshort).arg(0xb,2,16,QChar('0')), STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_0C = 0x1156, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_0C = 0x1156, UNKNOWN, SESSION, "PRS1_0C", QString(unknownname).arg(0xc,2,16,QChar('0')), QString(unknowndesc).arg(0xc,2,16,QChar('0')), QString(unknownshort).arg(0xc,2,16,QChar('0')), STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_0E = 0x1157, MINOR_FLAG, SESSION, + channel.add(GRP_CPAP, new Channel(PRS1_0E = 0x1157, UNKNOWN, SESSION, "PRS1_0E", QString(unknownname).arg(0xe,2,16,QChar('0')), QString(unknowndesc).arg(0xe,2,16,QChar('0')), QString(unknownshort).arg(0xe,2,16,QChar('0')), STR_UNIT_Unknown, DEFAULT, QColor("black"))); - channel.add(GRP_CPAP, new Channel(PRS1_12 = 0x1159, MINOR_FLAG, SESSION, - "PRS1_12", - QString(unknownname).arg(0x12,2,16,QChar('0')), - QString(unknowndesc).arg(0x12,2,16,QChar('0')), - QString(unknownshort).arg(0x12,2,16,QChar('0')), - STR_UNIT_Unknown, - DEFAULT, QColor("black"))); +// channel.add(GRP_CPAP, new Channel(PRS1_12 = 0x1159, UNKNOWN, SESSION, +// "PRS1_12", +// QString(unknownname).arg(0x12,2,16,QChar('0')), +// QString(unknowndesc).arg(0x12,2,16,QChar('0')), +// QString(unknownshort).arg(0x12,2,16,QChar('0')), +// STR_UNIT_Unknown, +// DEFAULT, QColor("black"))); channel.add(GRP_CPAP, new Channel(PRS1_TimedBreath = 0x1180, MINOR_FLAG, SESSION, diff --git a/sleepyhead/SleepLib/machine.cpp b/sleepyhead/SleepLib/machine.cpp index 685553ac..db33e174 100644 --- a/sleepyhead/SleepLib/machine.cpp +++ b/sleepyhead/SleepLib/machine.cpp @@ -670,7 +670,7 @@ bool Machine::Save() return true; } -QList Machine::availableChannels(schema::ChanType chantype) +QList Machine::availableChannels(quint32 chantype) { QHash chanhash; @@ -687,7 +687,7 @@ QList Machine::availableChannels(schema::ChanType chantype) for (int i=0; i < size; ++i) { ChannelID code = sess->availableChannels().at(i); const schema::Channel & chan = schema::channel[code]; - if (chan.type() == chantype) { + if (chan.type() & chantype) { chanhash[code]++; } } diff --git a/sleepyhead/SleepLib/machine.h b/sleepyhead/SleepLib/machine.h index f1bf2433..b44d2e23 100644 --- a/sleepyhead/SleepLib/machine.h +++ b/sleepyhead/SleepLib/machine.h @@ -194,7 +194,7 @@ class Machine void setLoaderName(QString value); - QList availableChannels(schema::ChanType chantype); + QList availableChannels(quint32 chantype); MachineLoader * loader() { return m_loader; } diff --git a/sleepyhead/SleepLib/profiles.h b/sleepyhead/SleepLib/profiles.h index 9024d0e8..32e2d63e 100644 --- a/sleepyhead/SleepLib/profiles.h +++ b/sleepyhead/SleepLib/profiles.h @@ -329,6 +329,7 @@ const QString STR_US_PrefCalcPercentile = "PrefCalcPercentile"; const QString STR_US_PrefCalcMax = "PrefCalcMax"; const QString STR_US_TooltipTimeout = "TooltipTimeout"; const QString STR_US_ScrollDampening = "ScrollDampening"; +const QString STR_US_ShowUnknownFlags = "ShowUnknownFlags"; const QString STR_US_StatReportMode = "StatReportMode"; // Parent class for subclasses that manipulate the profile. @@ -763,6 +764,7 @@ class UserSettings : public ProfileSettings initPref(STR_US_TooltipTimeout, (int)2500); initPref(STR_US_ScrollDampening, (int)50); initPref(STR_US_StatReportMode, 0); + initPref(STR_US_ShowUnknownFlags, false); } UnitSystem unitSystem() const { return (UnitSystem)getPref(STR_US_UnitSystem).toInt(); } @@ -779,6 +781,7 @@ class UserSettings : public ProfileSettings int tooltipTimeout() const { return getPref(STR_US_TooltipTimeout).toInt(); } int scrollDampening() const { return getPref(STR_US_ScrollDampening).toInt(); } int statReportMode() const { return getPref(STR_US_StatReportMode).toInt(); } + bool showUnknownFlags() const { return getPref(STR_US_ShowUnknownFlags).toBool(); } void setUnitSystem(UnitSystem us) { setPref(STR_US_UnitSystem, (int)us); } void setEventWindowSize(double size) { setPref(STR_US_EventWindowSize, size); } @@ -794,6 +797,7 @@ class UserSettings : public ProfileSettings void setTooltipTimeout(int i) { setPref(STR_US_TooltipTimeout, i); } void setScrollDampening(int i) { setPref(STR_US_ScrollDampening, i); } void setStatReportMode(int i) { setPref(STR_US_StatReportMode, i); } + void setShowUnknownFlags(bool b) { setPref(STR_US_ShowUnknownFlags, b); } }; //! \brief Returns a count of all files & directories in a supplied folder diff --git a/sleepyhead/SleepLib/schema.cpp b/sleepyhead/SleepLib/schema.cpp index 2f4b2115..2b67685a 100644 --- a/sleepyhead/SleepLib/schema.cpp +++ b/sleepyhead/SleepLib/schema.cpp @@ -391,12 +391,12 @@ void init() QObject::tr("Upright angle in degrees"), QObject::tr("Inclination"), STR_UNIT_Degrees, DEFAULT, QColor("dark magenta"))); - schema::channel.add(GRP_CPAP, new Channel(RMS9_MaskOnTime = 0x1025, SETTING, SESSION, + schema::channel.add(GRP_CPAP, new Channel(RMS9_MaskOnTime = 0x1025, DATA, SESSION, "MaskOnTime", QObject::tr("Mask On Time"), QObject::tr("Time started according to str.edf"), QObject::tr("Mask On Time"), STR_UNIT_Unknown, DEFAULT, Qt::black)); - schema::channel.add(GRP_CPAP, new Channel(CPAP_SummaryOnly = 0x1026, SETTING, SESSION, + schema::channel.add(GRP_CPAP, new Channel(CPAP_SummaryOnly = 0x1026, DATA, SESSION, "SummaryOnly", QObject::tr("Summary Only"), QObject::tr("CPAP Session contains summary data only"), QObject::tr("Summary Only"), STR_UNIT_Unknown, DEFAULT, Qt::black)); diff --git a/sleepyhead/SleepLib/schema.h b/sleepyhead/SleepLib/schema.h index 5c87a069..3d2907c1 100644 --- a/sleepyhead/SleepLib/schema.h +++ b/sleepyhead/SleepLib/schema.h @@ -41,6 +41,7 @@ enum ChanType { MINOR_FLAG = 8, SPAN = 16, WAVEFORM = 32, + UNKNOWN = 64, ALL = 0xFFFF }; diff --git a/sleepyhead/daily.cpp b/sleepyhead/daily.cpp index c5038e80..a3b27391 100644 --- a/sleepyhead/daily.cpp +++ b/sleepyhead/daily.cpp @@ -1285,6 +1285,10 @@ QString Daily::getEventBreakdown(Day * cpap) return html; } +float brightness(QColor color) { + return color.redF()*0.299 + color.greenF()*0.587 + color.blueF()*0.114; +} + QString Daily::getSleepTime(Day * cpap, Day * oxi) { QString html; @@ -1317,6 +1321,7 @@ QString Daily::getSleepTime(Day * cpap, Day * oxi) } + void Daily::Load(QDate date) { dateDisplay->setText(""+date.toString(Qt::SystemLocaleLongDate)+""); @@ -1401,28 +1406,17 @@ void Daily::Load(QDate date) ui->eventsCombo->clear(); if (cpap) { - QMap flags; - for (int i=0; i< cpap->size(); ++i) { - Session * sess = cpap->sessions.at(i); - QHash >::iterator it; - for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) { - ChannelID code = it.key(); - schema::Channel * chan = &schema::channel[code]; - const QString & str = chan->label(); - if (flags.contains(str)) continue; + quint32 chans = schema::SPAN | schema::FLAG | schema::MINOR_FLAG; + if (p_profile->general->showUnknownFlags()) chans |= schema::UNKNOWN; - if ((chan->type() == schema::FLAG) || (chan->type() == schema::MINOR_FLAG) || (chan->type() == schema::SPAN)) { - flags[str] = chan; - } - } - } + QList available = cpap->getSortedMachineChannels(chans); + + for (int i=0; i < available.size(); ++i) { + ChannelID code = available.at(i); + schema::Channel & chan = schema::channel[code]; + ui->eventsCombo->addItem(chan.enabled() ? *icon_on : * icon_off, chan.label(), code); + ui->eventsCombo->setItemData(i, chan.fullname(), Qt::ToolTipRole); - QMap::iterator fit; - int c = 0; - for (fit = flags.begin(); fit != flags.end(); ++fit) { - ui->eventsCombo->addItem(fit.value()->enabled() ? *icon_on : * icon_off, fit.key(), fit.value()->id()); - ui->eventsCombo->setItemData(c, fit.value()->fullname(), Qt::ToolTipRole); - c++; } } @@ -1464,46 +1458,52 @@ void Daily::Load(QDate date) html+=getCPAPInformation(cpap); html+=getSleepTime(cpap,oxi); - struct ChannelInfo { - ChannelID id; - QColor color; - QColor color2; - EventDataType value; - }; - ChannelInfo chans[]={ - { CPAP_Hypopnea, COLOR_Hypopnea, Qt::white, hi=(cpap->count(CPAP_ExP)+cpap->count(CPAP_Hypopnea))/hours }, - { CPAP_Obstructive, COLOR_Obstructive, Qt::black, oai=cpap->count(CPAP_Obstructive)/hours }, - { CPAP_Apnea, COLOR_Apnea, Qt::black, uai=cpap->count(CPAP_Apnea)/hours }, - { CPAP_ClearAirway, COLOR_ClearAirway, Qt::black, cai=cpap->count(CPAP_ClearAirway)/hours }, - { CPAP_NRI, COLOR_NRI, Qt::black, nri=cpap->count(CPAP_NRI)/hours }, - { CPAP_FlowLimit, COLOR_FlowLimit, Qt::white, fli=cpap->count(CPAP_FlowLimit)/hours }, - { CPAP_SensAwake, COLOR_SensAwake, Qt::black, sai=cpap->count(CPAP_SensAwake)/hours }, - { CPAP_ExP, COLOR_ExP, Qt::black, exp=cpap->count(CPAP_ExP)/hours }, - { CPAP_RERA, COLOR_RERA, Qt::black, rei=cpap->count(CPAP_RERA)/hours }, - { CPAP_VSnore, COLOR_VibratorySnore, Qt::black, vs=cpap->count(CPAP_VSnore)/cpap->hours() }, - { CPAP_VSnore2, COLOR_VibratorySnore, Qt::black, vs2=cpap->count(CPAP_VSnore2)/cpap->hours() }, - { CPAP_LeakFlag, COLOR_LeakFlag, Qt::black, lki=cpap->count(CPAP_LeakFlag)/hours }, - { CPAP_LargeLeak, COLOR_LargeLeak, Qt::black, lk2=(100.0/cpap->hours())*(cpap->sum(CPAP_LargeLeak)/3600.0) }, - { CPAP_CSR, COLOR_CSR, Qt::black, csr=(100.0/cpap->hours())*(cpap->sum(CPAP_CSR)/3600.0) }, - { CPAP_UserFlag1, COLOR_UserFlag1, Qt::black, uf1=cpap->count(CPAP_UserFlag1)/hours }, - { CPAP_UserFlag2, COLOR_UserFlag2, Qt::black, uf2=cpap->count(CPAP_UserFlag2)/hours }, - - }; - int numchans=sizeof(chans)/sizeof(ChannelInfo); - html+="\n"; - for (int i=0;ichannelHasData(chans[i].id)) - continue; - if ((cpap->machine->loaderName() == STR_MACH_PRS1) && (chans[i].id == CPAP_VSnore)) - continue; - html+=QString("\n") - .arg(chans[i].color.name()).arg(chans[i].color2.name()).arg(schema::channel[chans[i].id].fullname()).arg(chans[i].value,0,'f',2).arg(chans[i].id); - // keep in case tooltips are needed - //html+=QString("\n") - // .arg(chans[i].color.name()).arg(chans[i].color2.name()).arg(chans[i].name).arg(schema::channel[chans[i].id].description()).arg(chans[i].value,0,'f',2).arg(chans[i].id); + + quint32 zchans = schema::SPAN | schema::FLAG; + bool show_minors = true; + if (p_profile->general->showUnknownFlags()) zchans |= schema::UNKNOWN; + + if (show_minors) zchans |= schema::MINOR_FLAG; + QList available = cpap->getSortedMachineChannels(zchans); + + for (int i=0; i < available.size(); ++i) { + ChannelID code = available.at(i); + schema::Channel & chan = schema::channel[code]; + if (!chan.enabled()) continue; + QString data; + if (chan.type() == schema::SPAN) { + EventDataType val = (100.0 / hours)*(cpap->sum(code)/3600.0); + data = QString("%1%").arg(val,0,'f',2); + } else if (chan.type() == schema::FLAG) { + EventDataType val = vs=cpap->count(code) / hours; + data = QString("%1").arg(val,0,'f',2); + } else if (chan.type() == schema::MINOR_FLAG) { + EventDataType val = vs=cpap->count(code) / hours; + data = QString("%1").arg(val,0,'f',2); + } else if (chan.type() == schema::UNKNOWN) { + EventDataType val = vs=cpap->count(code) / hours; + data = QString("%1").arg(val,0,'f',2); + } + QColor altcolor = (brightness(chan.defaultColor()) < 0.3) ? Qt::white : Qt::black; // pick a contrasting color + html+=QString("\n") + .arg(chan.defaultColor().name()).arg(altcolor.name()).arg(chan.fullname()).arg(data).arg(code); } + + +// for (int i=0;ichannelHasData(chans[i].id)) +// continue; +// if ((cpap->machine->loaderName() == STR_MACH_PRS1) && (chans[i].id == CPAP_VSnore)) +// continue; +// html+=QString("\n") +// .arg(schema::channel[chans[i].id].defaultColor().name()).arg(chans[i].color2.name()).arg(schema::channel[chans[i].id].fullname()).arg(chans[i].value,0,'f',2).arg(chans[i].id); + +// // keep in case tooltips are needed +// //html+=QString("\n") +// // .arg(chans[i].color.name()).arg(chans[i].color2.name()).arg(chans[i].name).arg(schema::channel[chans[i].id].description()).arg(chans[i].value,0,'f',2).arg(chans[i].id); +// } html+="
%3%4
%3%4%5
%3%4
%3%4
%3%4%5
"; html+="\n"; diff --git a/sleepyhead/preferencesdialog.cpp b/sleepyhead/preferencesdialog.cpp index 037cf2fa..7749fab4 100644 --- a/sleepyhead/preferencesdialog.cpp +++ b/sleepyhead/preferencesdialog.cpp @@ -189,6 +189,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) : ui->clockDrift->setValue(profile->cpap->clockDrift()); ui->skipEmptyDays->setChecked(profile->general->skipEmptyDays()); + ui->showUnknownFlags->setChecked(profile->general->showUnknownFlags()); ui->enableMultithreading->setChecked(profile->session->multithreading()); ui->cacheSessionData->setChecked(profile->session->cacheSessions()); ui->animationsAndTransitionsCheckbox->setChecked(profile->appearance->animations()); @@ -312,6 +313,10 @@ void PreferencesDialog::InitChanInfo() hdr->setEditable(false); chanModel->appendRow(hdr); + toplevel[schema::UNKNOWN] = hdr = new QStandardItem(tr("Unknown Channels")); + hdr->setEditable(false); + chanModel->appendRow(hdr); + ui->chanView->setAlternatingRowColors(true); // ui->graphView->setFirstColumnSpanned(0,daily->index(),true); // Crashes on windows.. Why do I need this again? @@ -468,6 +473,7 @@ bool PreferencesDialog::Save() profile->general->setTooltipTimeout(ui->tooltipTimeoutSlider->value() * 50); profile->general->setScrollDampening(ui->scrollDampeningSlider->value() * 10); + profile->general->setShowUnknownFlags(ui->showUnknownFlags->isChecked()); profile->session->setMultithreading(ui->enableMultithreading->isChecked()); profile->session->setCacheSessions(ui->cacheSessionData->isChecked()); profile->cpap->setMaskDescription(ui->maskDescription->text()); diff --git a/sleepyhead/preferencesdialog.ui b/sleepyhead/preferencesdialog.ui index c37f9a0c..d762425b 100644 --- a/sleepyhead/preferencesdialog.ui +++ b/sleepyhead/preferencesdialog.ui @@ -51,7 +51,7 @@ - 1 + 5 @@ -1750,6 +1750,16 @@ as this is the only value available on summary-only days. 4 + + + + Bypass the login screen and load the most recent User Profile + + + Skip Login Screen + + + @@ -1771,13 +1781,13 @@ Mainly affects the importer. - - + + - Bypass the login screen and load the most recent User Profile + Show flags for machine detected events that haven't been identified yet. - Skip Login Screen + Show Unknown Flags