More color and flag consistency cleanups

This commit is contained in:
Mark Watkins 2014-08-08 06:27:23 +10:00
parent df122db7a4
commit ce2ac29cd0
14 changed files with 217 additions and 151 deletions

View File

@ -78,11 +78,13 @@ void gFlagsGroup::SetDay(Day *d)
schema::channel[CPAP_VSnore].setOrder(7); schema::channel[CPAP_VSnore].setOrder(7);
schema::channel[CPAP_VSnore2].setOrder(8); schema::channel[CPAP_VSnore2].setOrder(8);
schema::channel[CPAP_ExP].setOrder(6); schema::channel[CPAP_ExP].setOrder(6);
schema::channel[CPAP_UserFlag1].setOrder(256);
schema::channel[CPAP_UserFlag2].setOrder(257);
availableChans.clear(); quint32 z = schema::FLAG | schema::SPAN;
availableChans.append(d->machine->availableChannels(schema::FLAG)); if (p_profile->general->showUnknownFlags()) z |= schema::UNKNOWN;
availableChans.append(d->machine->availableChannels(schema::SPAN)); availableChans = d->getSortedMachineChannels(z);
m_rebuild_cpap = (availableChans.size() == 0); m_rebuild_cpap = (availableChans.size() == 0);
@ -99,33 +101,22 @@ void gFlagsGroup::SetDay(Day *d)
schema::Channel * chan = &schema::channel[code]; schema::Channel * chan = &schema::channel[code];
if (chan->type() == schema::FLAG) { if (chan->type() == schema::FLAG) {
chans[code] = chan; availableChans.push_back(code);
} else if (chan->type() == schema::MINOR_FLAG) { } else if (chan->type() == schema::MINOR_FLAG) {
// chans[code] = chan; availableChans.push_back(code);
} else if (chan->type() == schema::SPAN) { } 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(); availableChans = chans.keys();
} }
QMultiMap<int, ChannelID> order; lvisible.clear();
for (int i=0; i < availableChans.size(); ++i) { for (int i=0; i < availableChans.size(); ++i) {
ChannelID code = availableChans.at(i); ChannelID code = availableChans.at(i);
order.insert(schema::channel[code].order(), code);
}
QMultiMap<int, ChannelID>::iterator it;
for (int i=0;i <lvisible.size(); i++) {
delete lvisible.at(i);
}
lvisible.clear();
for (it = order.begin(); it != order.end(); ++it) {
ChannelID code = it.value();
// const schema::Channel & chan = schema::channel[code]; // const schema::Channel & chan = schema::channel[code];
gFlagsLine * fl = new gFlagsLine(code); gFlagsLine * fl = new gFlagsLine(code);
@ -355,35 +346,7 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion &region)
np -= idx; np -= idx;
if (chan.type() == schema::FLAG) { if (chan.type() == schema::SPAN) {
///////////////////////////////////////////////////////////////////////////
// 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));
}
} else if (chan.type() == schema::SPAN) {
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Draw Event Flag Spans // Draw Event Flag Spans
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -416,6 +379,35 @@ void gFlagsLine::paint(QPainter &painter, gGraph &w, const QRegion &region)
} }
} }
} 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));
}
} }
} }
} }

View File

@ -405,6 +405,11 @@ void gGraphView::dumpInfo()
case schema::WAVEFORM: case schema::WAVEFORM:
text = "WAVEFORM: "; text = "WAVEFORM: ";
break; break;
case schema::UNKNOWN:
text = "UNKNOWN: ";
break;
default:
break;
} }
QStringList str; QStringList str;
for (int i=0; i< lit.value().size(); ++i) { for (int i=0; i< lit.value().size(); ++i) {

View File

@ -158,31 +158,55 @@ skipcheck:
flags.clear(); flags.clear();
for (int i=0; i< m_day->size(); ++i) { quint32 z = schema::FLAG | schema::MINOR_FLAG | schema::SPAN;
Session * sess = m_day->sessions.at(i); if (p_profile->general->showUnknownFlags()) z |= schema::UNKNOWN;
QHash<ChannelID, QVector<EventList *> >::iterator it; QList<ChannelID> available = m_day->getSortedMachineChannels(z);
for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) {
ChannelID code = it.key();
if (flags.contains(code)) continue; for (int i=0; i < available.size(); ++i) {
ChannelID code = available.at(i);
schema::Channel * chan = &schema::channel[code]; schema::Channel * chan = &schema::channel[code];
gLineOverlayBar * lob = nullptr; gLineOverlayBar * lob = nullptr;
if (chan->type() == schema::FLAG) { if (chan->type() == schema::FLAG) {
lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Bar); lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Bar);
} else if (chan->type() == schema::MINOR_FLAG) { } else if ((chan->type() == schema::MINOR_FLAG) || (chan->type() == schema::UNKNOWN)) {
lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Dot); lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Dot);
} else if (chan->type() == schema::SPAN) { } else if (chan->type() == schema::SPAN) {
lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span); lob = new gLineOverlayBar(code, chan->defaultColor(), chan->label(), FT_Span);
} }
if (lob != nullptr) { if (lob != nullptr) {
lob->setOverlayDisplayType((m_codes[0] == CPAP_FlowRate) ? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom); lob->setOverlayDisplayType((m_codes[0] == CPAP_FlowRate) ? (OverlayDisplayType)p_profile->appearance->overlayType() : ODT_TopAndBottom);
lob->SetDay(m_day); lob->SetDay(m_day);
flags[code] = lob; flags[code] = lob;
}
} }
} }
// for (int i=0; i< m_day->size(); ++i) {
// Session * sess = m_day->sessions.at(i);
// QHash<ChannelID, QVector<EventList *> >::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() EventDataType gLineChart::Miny()
{ {

View File

@ -900,6 +900,27 @@ void Day::CloseEvents()
} }
} }
QList<ChannelID> Day::getSortedMachineChannels(quint32 chantype)
{
QList<ChannelID> available = machine->availableChannels(chantype);
QMultiMap<int, ChannelID> order;
for (int i=0; i < available.size(); ++i) {
ChannelID code = available.at(i);
order.insert(schema::channel[code].order(), code);
}
QMultiMap<int, ChannelID>::iterator it;
QList<ChannelID> channels;
for (it = order.begin(); it != order.end(); ++it) {
ChannelID code = it.value();
channels.append(code);
}
return channels;
}
qint64 Day::first() qint64 Day::first()
{ {
qint64 date = 0; qint64 date = 0;

View File

@ -176,8 +176,11 @@ class Day
//! \brief Returns true if this day contains the supplied settings Channel id //! \brief Returns true if this day contains the supplied settings Channel id
bool settingExists(ChannelID id); bool settingExists(ChannelID id);
//! \brief Removes a session from this day
bool removeSession(Session *sess); bool removeSession(Session *sess);
//! \brief Returns a list of channels of supplied types, according to channel orders
QList<ChannelID> getSortedMachineChannels(quint32 chantype);
// Some ugly CPAP specific stuff // Some ugly CPAP specific stuff
QString getCPAPMode(); QString getCPAPMode();

View File

@ -874,7 +874,7 @@ bool PRS1Import::ParseF0Events()
EventList *FL = session->AddEventList(CPAP_FlowLimit, EVL_Event); EventList *FL = session->AddEventList(CPAP_FlowLimit, EVL_Event);
EventList *VS = session->AddEventList(CPAP_VSnore, EVL_Event); EventList *VS = session->AddEventList(CPAP_VSnore, EVL_Event);
EventList *VS2 = session->AddEventList(CPAP_VSnore2, 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[12] = session->AddEventList(PRS1_0B, EVL_Event);
Code[17] = session->AddEventList(PRS1_0E, EVL_Event); Code[17] = session->AddEventList(PRS1_0E, EVL_Event);
@ -2137,7 +2137,7 @@ void PRS1Loader::initChannels()
QString unknownname=QObject::tr("PRS1_%1"); QString unknownname=QObject::tr("PRS1_%1");
QString unknownshort=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", "PRS1_00",
QString(unknownname).arg(0,2,16,QChar('0')), QString(unknownname).arg(0,2,16,QChar('0')),
QString(unknowndesc).arg(0,2,16,QChar('0')), QString(unknowndesc).arg(0,2,16,QChar('0')),
@ -2145,7 +2145,7 @@ void PRS1Loader::initChannels()
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); 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", "PRS1_01",
QString(unknownname).arg(1,2,16,QChar('0')), QString(unknownname).arg(1,2,16,QChar('0')),
QString(unknowndesc).arg(1,2,16,QChar('0')), QString(unknowndesc).arg(1,2,16,QChar('0')),
@ -2153,7 +2153,7 @@ void PRS1Loader::initChannels()
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); 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", "PRS1_08",
QString(unknownname).arg(8,2,16,QChar('0')), QString(unknownname).arg(8,2,16,QChar('0')),
QString(unknowndesc).arg(8,2,16,QChar('0')), QString(unknowndesc).arg(8,2,16,QChar('0')),
@ -2161,41 +2161,41 @@ void PRS1Loader::initChannels()
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); 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", "PRS1_0A",
QString(unknownname).arg(0xa,2,16,QChar('0')), QString(unknownname).arg(0xa,2,16,QChar('0')),
QString(unknowndesc).arg(0xa,2,16,QChar('0')), QString(unknowndesc).arg(0xa,2,16,QChar('0')),
QString(unknownshort).arg(0xa,2,16,QChar('0')), QString(unknownshort).arg(0xa,2,16,QChar('0')),
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); 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", "PRS1_0B",
QString(unknownname).arg(0xb,2,16,QChar('0')), QString(unknownname).arg(0xb,2,16,QChar('0')),
QString(unknowndesc).arg(0xb,2,16,QChar('0')), QString(unknowndesc).arg(0xb,2,16,QChar('0')),
QString(unknownshort).arg(0xb,2,16,QChar('0')), QString(unknownshort).arg(0xb,2,16,QChar('0')),
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); 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", "PRS1_0C",
QString(unknownname).arg(0xc,2,16,QChar('0')), QString(unknownname).arg(0xc,2,16,QChar('0')),
QString(unknowndesc).arg(0xc,2,16,QChar('0')), QString(unknowndesc).arg(0xc,2,16,QChar('0')),
QString(unknownshort).arg(0xc,2,16,QChar('0')), QString(unknownshort).arg(0xc,2,16,QChar('0')),
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); 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", "PRS1_0E",
QString(unknownname).arg(0xe,2,16,QChar('0')), QString(unknownname).arg(0xe,2,16,QChar('0')),
QString(unknowndesc).arg(0xe,2,16,QChar('0')), QString(unknowndesc).arg(0xe,2,16,QChar('0')),
QString(unknownshort).arg(0xe,2,16,QChar('0')), QString(unknownshort).arg(0xe,2,16,QChar('0')),
STR_UNIT_Unknown, STR_UNIT_Unknown,
DEFAULT, QColor("black"))); DEFAULT, QColor("black")));
channel.add(GRP_CPAP, new Channel(PRS1_12 = 0x1159, MINOR_FLAG, SESSION, // channel.add(GRP_CPAP, new Channel(PRS1_12 = 0x1159, UNKNOWN, SESSION,
"PRS1_12", // "PRS1_12",
QString(unknownname).arg(0x12,2,16,QChar('0')), // QString(unknownname).arg(0x12,2,16,QChar('0')),
QString(unknowndesc).arg(0x12,2,16,QChar('0')), // QString(unknowndesc).arg(0x12,2,16,QChar('0')),
QString(unknownshort).arg(0x12,2,16,QChar('0')), // QString(unknownshort).arg(0x12,2,16,QChar('0')),
STR_UNIT_Unknown, // STR_UNIT_Unknown,
DEFAULT, QColor("black"))); // DEFAULT, QColor("black")));
channel.add(GRP_CPAP, new Channel(PRS1_TimedBreath = 0x1180, MINOR_FLAG, SESSION, channel.add(GRP_CPAP, new Channel(PRS1_TimedBreath = 0x1180, MINOR_FLAG, SESSION,

View File

@ -670,7 +670,7 @@ bool Machine::Save()
return true; return true;
} }
QList<ChannelID> Machine::availableChannels(schema::ChanType chantype) QList<ChannelID> Machine::availableChannels(quint32 chantype)
{ {
QHash<ChannelID, int> chanhash; QHash<ChannelID, int> chanhash;
@ -687,7 +687,7 @@ QList<ChannelID> Machine::availableChannels(schema::ChanType chantype)
for (int i=0; i < size; ++i) { for (int i=0; i < size; ++i) {
ChannelID code = sess->availableChannels().at(i); ChannelID code = sess->availableChannels().at(i);
const schema::Channel & chan = schema::channel[code]; const schema::Channel & chan = schema::channel[code];
if (chan.type() == chantype) { if (chan.type() & chantype) {
chanhash[code]++; chanhash[code]++;
} }
} }

View File

@ -194,7 +194,7 @@ class Machine
void setLoaderName(QString value); void setLoaderName(QString value);
QList<ChannelID> availableChannels(schema::ChanType chantype); QList<ChannelID> availableChannels(quint32 chantype);
MachineLoader * loader() { return m_loader; } MachineLoader * loader() { return m_loader; }

View File

@ -329,6 +329,7 @@ const QString STR_US_PrefCalcPercentile = "PrefCalcPercentile";
const QString STR_US_PrefCalcMax = "PrefCalcMax"; const QString STR_US_PrefCalcMax = "PrefCalcMax";
const QString STR_US_TooltipTimeout = "TooltipTimeout"; const QString STR_US_TooltipTimeout = "TooltipTimeout";
const QString STR_US_ScrollDampening = "ScrollDampening"; const QString STR_US_ScrollDampening = "ScrollDampening";
const QString STR_US_ShowUnknownFlags = "ShowUnknownFlags";
const QString STR_US_StatReportMode = "StatReportMode"; const QString STR_US_StatReportMode = "StatReportMode";
// Parent class for subclasses that manipulate the profile. // 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_TooltipTimeout, (int)2500);
initPref(STR_US_ScrollDampening, (int)50); initPref(STR_US_ScrollDampening, (int)50);
initPref(STR_US_StatReportMode, 0); initPref(STR_US_StatReportMode, 0);
initPref(STR_US_ShowUnknownFlags, false);
} }
UnitSystem unitSystem() const { return (UnitSystem)getPref(STR_US_UnitSystem).toInt(); } 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 tooltipTimeout() const { return getPref(STR_US_TooltipTimeout).toInt(); }
int scrollDampening() const { return getPref(STR_US_ScrollDampening).toInt(); } int scrollDampening() const { return getPref(STR_US_ScrollDampening).toInt(); }
int statReportMode() const { return getPref(STR_US_StatReportMode).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 setUnitSystem(UnitSystem us) { setPref(STR_US_UnitSystem, (int)us); }
void setEventWindowSize(double size) { setPref(STR_US_EventWindowSize, size); } 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 setTooltipTimeout(int i) { setPref(STR_US_TooltipTimeout, i); }
void setScrollDampening(int i) { setPref(STR_US_ScrollDampening, i); } void setScrollDampening(int i) { setPref(STR_US_ScrollDampening, i); }
void setStatReportMode(int i) { setPref(STR_US_StatReportMode, 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 //! \brief Returns a count of all files & directories in a supplied folder

View File

@ -391,12 +391,12 @@ void init()
QObject::tr("Upright angle in degrees"), QObject::tr("Inclination"), STR_UNIT_Degrees, QObject::tr("Upright angle in degrees"), QObject::tr("Inclination"), STR_UNIT_Degrees,
DEFAULT, QColor("dark magenta"))); 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"), "MaskOnTime", QObject::tr("Mask On Time"),
QObject::tr("Time started according to str.edf"), QObject::tr("Mask On Time"), STR_UNIT_Unknown, QObject::tr("Time started according to str.edf"), QObject::tr("Mask On Time"), STR_UNIT_Unknown,
DEFAULT, Qt::black)); 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"), "SummaryOnly", QObject::tr("Summary Only"),
QObject::tr("CPAP Session contains summary data only"), QObject::tr("Summary Only"), STR_UNIT_Unknown, QObject::tr("CPAP Session contains summary data only"), QObject::tr("Summary Only"), STR_UNIT_Unknown,
DEFAULT, Qt::black)); DEFAULT, Qt::black));

View File

@ -41,6 +41,7 @@ enum ChanType {
MINOR_FLAG = 8, MINOR_FLAG = 8,
SPAN = 16, SPAN = 16,
WAVEFORM = 32, WAVEFORM = 32,
UNKNOWN = 64,
ALL = 0xFFFF ALL = 0xFFFF
}; };

View File

@ -1285,6 +1285,10 @@ QString Daily::getEventBreakdown(Day * cpap)
return html; 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 Daily::getSleepTime(Day * cpap, Day * oxi)
{ {
QString html; QString html;
@ -1317,6 +1321,7 @@ QString Daily::getSleepTime(Day * cpap, Day * oxi)
} }
void Daily::Load(QDate date) void Daily::Load(QDate date)
{ {
dateDisplay->setText("<i>"+date.toString(Qt::SystemLocaleLongDate)+"</i>"); dateDisplay->setText("<i>"+date.toString(Qt::SystemLocaleLongDate)+"</i>");
@ -1401,28 +1406,17 @@ void Daily::Load(QDate date)
ui->eventsCombo->clear(); ui->eventsCombo->clear();
if (cpap) { if (cpap) {
QMap<QString, schema::Channel *> flags; quint32 chans = schema::SPAN | schema::FLAG | schema::MINOR_FLAG;
for (int i=0; i< cpap->size(); ++i) { if (p_profile->general->showUnknownFlags()) chans |= schema::UNKNOWN;
Session * sess = cpap->sessions.at(i);
QHash<ChannelID, QVector<EventList *> >::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;
if ((chan->type() == schema::FLAG) || (chan->type() == schema::MINOR_FLAG) || (chan->type() == schema::SPAN)) { QList<ChannelID> available = cpap->getSortedMachineChannels(chans);
flags[str] = chan;
} 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<QString, schema::Channel *>::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+=getCPAPInformation(cpap);
html+=getSleepTime(cpap,oxi); 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+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"; html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n";
for (int i=0;i<numchans;i++) {
if (!cpap->channelHasData(chans[i].id))
continue;
if ((cpap->machine->loaderName() == STR_MACH_PRS1) && (chans[i].id == CPAP_VSnore))
continue;
html+=QString("<tr><td align='left' bgcolor='%1'><b><font color='%2'><a href='event=%5'>%3</a></font></b></td><td width=20% bgcolor='%1'><b><font color='%2'>%4</font></b></td></tr>\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("<tr><td align='left' bgcolor='%1'><b><font color='%2'><a class=info href='event=%6'>%3<span>%4</span></a></font></b></td><td width=20% bgcolor='%1'><b><font color='%2'>%5</font></b></td></tr>\n") quint32 zchans = schema::SPAN | schema::FLAG;
// .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); bool show_minors = true;
if (p_profile->general->showUnknownFlags()) zchans |= schema::UNKNOWN;
if (show_minors) zchans |= schema::MINOR_FLAG;
QList<ChannelID> 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("<tr><td align='left' bgcolor='%1'><b><font color='%2'><a href='event=%5'>%3</a></font></b></td><td width=20% bgcolor='%1'><b><font color='%2'>%4</font></b></td></tr>\n")
.arg(chan.defaultColor().name()).arg(altcolor.name()).arg(chan.fullname()).arg(data).arg(code);
} }
// for (int i=0;i<numchans;i++) {
// if (!cpap->channelHasData(chans[i].id))
// continue;
// if ((cpap->machine->loaderName() == STR_MACH_PRS1) && (chans[i].id == CPAP_VSnore))
// continue;
// html+=QString("<tr><td align='left' bgcolor='%1'><b><font color='%2'><a href='event=%5'>%3</a></font></b></td><td width=20% bgcolor='%1'><b><font color='%2'>%4</font></b></td></tr>\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("<tr><td align='left' bgcolor='%1'><b><font color='%2'><a class=info href='event=%6'>%3<span>%4</span></a></font></b></td><td width=20% bgcolor='%1'><b><font color='%2'>%5</font></b></td></tr>\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+="</table>"; html+="</table>";
html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n"; html+="<table cellspacing=0 cellpadding=0 border=0 width='100%'>\n";

View File

@ -189,6 +189,7 @@ PreferencesDialog::PreferencesDialog(QWidget *parent, Profile *_profile) :
ui->clockDrift->setValue(profile->cpap->clockDrift()); ui->clockDrift->setValue(profile->cpap->clockDrift());
ui->skipEmptyDays->setChecked(profile->general->skipEmptyDays()); ui->skipEmptyDays->setChecked(profile->general->skipEmptyDays());
ui->showUnknownFlags->setChecked(profile->general->showUnknownFlags());
ui->enableMultithreading->setChecked(profile->session->multithreading()); ui->enableMultithreading->setChecked(profile->session->multithreading());
ui->cacheSessionData->setChecked(profile->session->cacheSessions()); ui->cacheSessionData->setChecked(profile->session->cacheSessions());
ui->animationsAndTransitionsCheckbox->setChecked(profile->appearance->animations()); ui->animationsAndTransitionsCheckbox->setChecked(profile->appearance->animations());
@ -312,6 +313,10 @@ void PreferencesDialog::InitChanInfo()
hdr->setEditable(false); hdr->setEditable(false);
chanModel->appendRow(hdr); chanModel->appendRow(hdr);
toplevel[schema::UNKNOWN] = hdr = new QStandardItem(tr("Unknown Channels"));
hdr->setEditable(false);
chanModel->appendRow(hdr);
ui->chanView->setAlternatingRowColors(true); ui->chanView->setAlternatingRowColors(true);
// ui->graphView->setFirstColumnSpanned(0,daily->index(),true); // Crashes on windows.. Why do I need this again? // 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->setTooltipTimeout(ui->tooltipTimeoutSlider->value() * 50);
profile->general->setScrollDampening(ui->scrollDampeningSlider->value() * 10); profile->general->setScrollDampening(ui->scrollDampeningSlider->value() * 10);
profile->general->setShowUnknownFlags(ui->showUnknownFlags->isChecked());
profile->session->setMultithreading(ui->enableMultithreading->isChecked()); profile->session->setMultithreading(ui->enableMultithreading->isChecked());
profile->session->setCacheSessions(ui->cacheSessionData->isChecked()); profile->session->setCacheSessions(ui->cacheSessionData->isChecked());
profile->cpap->setMaskDescription(ui->maskDescription->text()); profile->cpap->setMaskDescription(ui->maskDescription->text());

View File

@ -51,7 +51,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>1</number> <number>5</number>
</property> </property>
<widget class="QWidget" name="importTab"> <widget class="QWidget" name="importTab">
<attribute name="title"> <attribute name="title">
@ -1750,6 +1750,16 @@ as this is the only value available on summary-only days.</string>
<property name="spacing"> <property name="spacing">
<number>4</number> <number>4</number>
</property> </property>
<item row="1" column="0">
<widget class="QCheckBox" name="skipLoginScreen">
<property name="toolTip">
<string>Bypass the login screen and load the most recent User Profile</string>
</property>
<property name="text">
<string>Skip Login Screen</string>
</property>
</widget>
</item>
<item row="5" column="0"> <item row="5" column="0">
<widget class="QCheckBox" name="skipEmptyDays"> <widget class="QCheckBox" name="skipEmptyDays">
<property name="toolTip"> <property name="toolTip">
@ -1771,13 +1781,13 @@ Mainly affects the importer.</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="5" column="1">
<widget class="QCheckBox" name="skipLoginScreen"> <widget class="QCheckBox" name="showUnknownFlags">
<property name="toolTip"> <property name="toolTip">
<string>Bypass the login screen and load the most recent User Profile</string> <string>Show flags for machine detected events that haven't been identified yet.</string>
</property> </property>
<property name="text"> <property name="text">
<string>Skip Login Screen</string> <string>Show Unknown Flags</string>
</property> </property>
</widget> </widget>
</item> </item>