mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-17 11:10:45 +00:00
Machine availableChannels stuff and rebuild nag
This commit is contained in:
parent
ff3a9e6b90
commit
eb4ba53b08
@ -63,7 +63,6 @@ void gFlagsGroup::SetDay(Day *d)
|
|||||||
m_empty = true;
|
m_empty = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QHash<ChannelID, schema::Channel *> chans;
|
|
||||||
|
|
||||||
schema::channel[CPAP_CSR].setOrder(1);
|
schema::channel[CPAP_CSR].setOrder(1);
|
||||||
schema::channel[CPAP_CSR].setOrder(1);
|
schema::channel[CPAP_CSR].setOrder(1);
|
||||||
@ -80,56 +79,56 @@ void gFlagsGroup::SetDay(Day *d)
|
|||||||
schema::channel[CPAP_VSnore2].setOrder(8);
|
schema::channel[CPAP_VSnore2].setOrder(8);
|
||||||
schema::channel[CPAP_ExP].setOrder(6);
|
schema::channel[CPAP_ExP].setOrder(6);
|
||||||
|
|
||||||
alwaysVisible(CPAP_LargeLeak);
|
|
||||||
alwaysVisible(CPAP_Hypopnea);
|
|
||||||
alwaysVisible(CPAP_Obstructive);
|
|
||||||
|
|
||||||
|
availableChans.clear();
|
||||||
|
availableChans.append(d->machine->availableChannels(schema::FLAG));
|
||||||
|
availableChans.append(d->machine->availableChannels(schema::SPAN));
|
||||||
|
|
||||||
for (int i=0; i< m_day->size(); ++i) {
|
m_rebuild_cpap = (availableChans.size() == 0);
|
||||||
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 (chans.contains(code)) continue;
|
|
||||||
|
|
||||||
schema::Channel * chan = &schema::channel[code];
|
if (m_rebuild_cpap) {
|
||||||
|
QHash<ChannelID, schema::Channel *> chans;
|
||||||
|
|
||||||
if (chan->type() == schema::FLAG) {
|
for (int i=0; i< m_day->size(); ++i) {
|
||||||
chans[code] = chan;
|
Session * sess = m_day->sessions.at(i);
|
||||||
} else if (chan->type() == schema::MINOR_FLAG) {
|
QHash<ChannelID, QVector<EventList *> >::iterator it;
|
||||||
// chans[code] = chan;
|
for (it = sess->eventlist.begin(); it != sess->eventlist.end(); ++it) {
|
||||||
} else if (chan->type() == schema::SPAN) {
|
ChannelID code = it.key();
|
||||||
chans[code] = chan;
|
if (chans.contains(code)) continue;
|
||||||
|
|
||||||
|
schema::Channel * chan = &schema::channel[code];
|
||||||
|
|
||||||
|
if (chan->type() == schema::FLAG) {
|
||||||
|
chans[code] = chan;
|
||||||
|
} else if (chan->type() == schema::MINOR_FLAG) {
|
||||||
|
// chans[code] = chan;
|
||||||
|
} else if (chan->type() == schema::SPAN) {
|
||||||
|
chans[code] = chan;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
availableChans = chans.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i < m_alwaysvisible.size(); ++i) {
|
QMultiMap<int, ChannelID> order;
|
||||||
ChannelID code = m_alwaysvisible.at(i);
|
|
||||||
if (!chans.contains(code)) {
|
for (int i=0; i < availableChans.size(); ++i) {
|
||||||
schema::Channel * chan = &schema::channel[code];
|
ChannelID code = availableChans.at(i);
|
||||||
chans[code] = chan;
|
order.insert(schema::channel[code].order(), code);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QMultiMap<int, schema::Channel *> order;
|
QMultiMap<int, ChannelID>::iterator it;
|
||||||
QHash<ChannelID, schema::Channel *>::iterator cit;
|
|
||||||
|
|
||||||
for (cit = chans.begin(); cit != chans.end(); ++cit) {
|
|
||||||
int ord = schema::channel[cit.key()].order();
|
|
||||||
order.insert(ord, cit.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
QMultiMap<int, schema::Channel *>::iterator it;
|
|
||||||
|
|
||||||
for (int i=0;i <lvisible.size(); i++) {
|
for (int i=0;i <lvisible.size(); i++) {
|
||||||
delete lvisible.at(i);
|
delete lvisible.at(i);
|
||||||
}
|
}
|
||||||
lvisible.clear();
|
lvisible.clear();
|
||||||
for (it = order.begin(); it != order.end(); ++it) {
|
|
||||||
schema::Channel * chan = it.value();
|
|
||||||
|
|
||||||
gFlagsLine * fl = new gFlagsLine(chan->id());
|
for (it = order.begin(); it != order.end(); ++it) {
|
||||||
|
ChannelID code = it.value();
|
||||||
|
// const schema::Channel & chan = schema::channel[code];
|
||||||
|
|
||||||
|
gFlagsLine * fl = new gFlagsLine(code);
|
||||||
fl->SetDay(d);
|
fl->SetDay(d);
|
||||||
lvisible.push_back(fl);
|
lvisible.push_back(fl);
|
||||||
}
|
}
|
||||||
@ -155,11 +154,11 @@ void gFlagsGroup::SetDay(Day *d)
|
|||||||
|
|
||||||
m_empty = (cnt == 0);
|
m_empty = (cnt == 0);
|
||||||
|
|
||||||
// if (m_empty) {
|
if (m_empty) {
|
||||||
// if (d) {
|
if (d) {
|
||||||
// m_empty = !d->channelExists(CPAP_Pressure);
|
m_empty = !d->channelExists(CPAP_Pressure);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
m_barh = 0;
|
m_barh = 0;
|
||||||
}
|
}
|
||||||
@ -208,6 +207,14 @@ void gFlagsGroup::paint(QPainter &painter, gGraph &g, const QRegion ®ion)
|
|||||||
painter.drawLine(left - 1, top + height, left + width, top + height);
|
painter.drawLine(left - 1, top + height, left + width, top + height);
|
||||||
painter.drawLine(left + width, top + height, left + width, top);
|
painter.drawLine(left + width, top + height, left + width, top);
|
||||||
painter.drawLine(left + width, top, left - 1, top);
|
painter.drawLine(left + width, top, left - 1, top);
|
||||||
|
|
||||||
|
if (m_rebuild_cpap) {
|
||||||
|
|
||||||
|
QString txt = QObject::tr("Database Outdated\nPlease Rebuild CPAP Data");
|
||||||
|
painter.setFont(*bigfont);
|
||||||
|
painter.setPen(QPen(QColor(0,0,0,32)));
|
||||||
|
painter.drawText(region.boundingRect(), Qt::AlignCenter | Qt::AlignVCenter, txt);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
||||||
@ -240,6 +247,7 @@ bool gFlagsGroup::mouseMoveEvent(QMouseEvent *event, gGraph *graph)
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ class gFlagsLine: public Layer
|
|||||||
bool m_always_visible;
|
bool m_always_visible;
|
||||||
int total_lines, line_num;
|
int total_lines, line_num;
|
||||||
int m_lx, m_ly;
|
int m_lx, m_ly;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \class gFlagsGroup
|
/*! \class gFlagsGroup
|
||||||
@ -107,9 +108,12 @@ class gFlagsGroup: public LayerGroup
|
|||||||
|
|
||||||
QList<ChannelID> m_alwaysvisible;
|
QList<ChannelID> m_alwaysvisible;
|
||||||
|
|
||||||
|
QList<ChannelID> availableChans;
|
||||||
|
|
||||||
QVector<gFlagsLine *> lvisible;
|
QVector<gFlagsLine *> lvisible;
|
||||||
float m_barh;
|
float m_barh;
|
||||||
bool m_empty;
|
bool m_empty;
|
||||||
|
bool m_rebuild_cpap;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GFLAGSLINE_H
|
#endif // GFLAGSLINE_H
|
||||||
|
@ -674,19 +674,26 @@ QList<ChannelID> Machine::availableChannels(schema::ChanType chantype)
|
|||||||
{
|
{
|
||||||
QHash<ChannelID, int> chanhash;
|
QHash<ChannelID, int> chanhash;
|
||||||
|
|
||||||
|
|
||||||
// look through the daylist and return a list of available channels for this machine
|
// look through the daylist and return a list of available channels for this machine
|
||||||
QMap<QDate, Day *>::iterator dit;
|
QMap<QDate, Day *>::iterator dit;
|
||||||
QMap<QDate, Day *>::iterator day_end = day.end();
|
QMap<QDate, Day *>::iterator day_end = day.end();
|
||||||
for (dit = day.begin(); dit != day_end; ++dit) {
|
for (dit = day.begin(); dit != day_end; ++dit) {
|
||||||
QList<Session *>::iterator sess_end = dit.value()->end();
|
QList<Session *>::iterator sess_end = dit.value()->end();
|
||||||
|
|
||||||
for (QList<Session *>::iterator sit = dit.value()->begin(); sit != sess_end; ++sit) {
|
for (QList<Session *>::iterator sit = dit.value()->begin(); sit != sess_end; ++sit) {
|
||||||
// sessions desperately need to cache this..
|
Session * sess = (*sit);
|
||||||
///sit.value
|
int size = sess->availableChannels().size();
|
||||||
|
for (int i=0; i < size; ++i) {
|
||||||
|
ChannelID code = sess->availableChannels().at(i);
|
||||||
|
const schema::Channel & chan = schema::channel[code];
|
||||||
|
if (chan.type() == chantype) {
|
||||||
|
chanhash[code]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QList<ChannelID> channels;
|
return chanhash.keys();
|
||||||
|
|
||||||
return channels;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user