insure zero dotted line for flowRate is enabled with this release is installed

This commit is contained in:
LoudSnorer 2023-05-12 20:55:54 -04:00
parent e40474b6d3
commit e20ab60a30

View File

@ -3591,7 +3591,7 @@ void gGraphView::SaveDefaultSettings() {
} }
const quint32 gvmagic = 0x41756728; //'Aug(' const quint32 gvmagic = 0x41756728; //'Aug('
const quint16 gvversion = 4; const quint16 gvversion = 5; // version 5 has same format as 4, used to override settings in shg files on upgrade to version 5.
QString gGraphView::settingsFilename (QString title,QString folderName, QString ext) { QString gGraphView::settingsFilename (QString title,QString folderName, QString ext) {
if (folderName.size()==0) { if (folderName.size()==0) {
@ -3682,73 +3682,55 @@ bool gGraphView::LoadSettings(QString title,QString folderName)
in >> version; in >> version;
if (version < gvversion) { //The first version of OSCAR 1.0.0-release started at gvversion 4. and the OSCAR 1.4.0 still uses gvversion 4
qDebug() << "gGraphView" << title << "settings will be upgraded."; // This section of code is being simplified to remove dependances on lower version.
}
qint16 siz; //if (version < gvversion) {
in >> siz; //qDebug() << "gGraphView" << title << "settings will be upgraded.";
//}
qint16 numGraphs;
QString name; QString name;
float hght; float hght;
bool vis; bool vis;
EventDataType recminy, recmaxy; EventDataType recminy, recmaxy;
bool pinned; bool pinned;
short zoomy = 0; short zoomy = 0;
QList<gGraph *> neworder; QList<gGraph *> neworder;
QHash<QString, gGraph *>::iterator gi; QHash<QString, gGraph *>::iterator gi;
for (int i = 0; i < siz; i++) { in >> numGraphs;
for (int i = 0; i < numGraphs; i++) {
in >> name; in >> name;
in >> hght; in >> hght;
in >> vis; in >> vis;
in >> recminy; in >> recminy;
in >> recmaxy; in >> recmaxy;
//qDebug() << "Loading graph" << title << name; //qDebug() << "Loading graph" << title << name;
if (gvversion >= 1) { in >> zoomy;
in >> zoomy;
}
if (gvversion >= 2) {
in >> pinned;
}
in >> pinned;
QHash<ChannelID, bool> flags_enabled; QHash<ChannelID, bool> flags_enabled;
QHash<ChannelID, bool> plots_enabled; QHash<ChannelID, bool> plots_enabled;
QHash<ChannelID, QHash<quint32, bool> > dot_enabled; QHash<ChannelID, QHash<quint32, bool> > dot_enabled;
// Warning: Do not break the follow section up!!! // Warning: Do not break the follow section up!!!
quint32 layertype; quint32 layertype;
if (gvversion >= 4) { in >> layertype;
in >> layertype; if (layertype == LT_LineChart) {
if (layertype == LT_LineChart) { in >> flags_enabled;
in >> flags_enabled; in >> plots_enabled;
in >> plots_enabled; in >> dot_enabled;
in >> dot_enabled;
}
} }
gGraph *g = nullptr; gGraph *g = nullptr;
gi = m_graphsbyname.find(name);
if (version <= 2) { if (gi == m_graphsbyname.end()) {
continue; qDebug() << "Graph" << name << "has been renamed or removed";
// // Names were stored as translated strings, so look up title instead.
// g = nullptr;
// for (int z=0; z<m_graphs.size(); ++z) {
// if (m_graphs[z]->title() == name) {
// g = m_graphs[z];
// break;
// }
// }
} else { } else {
gi = m_graphsbyname.find(name); g = gi.value();
if (gi == m_graphsbyname.end()) {
qDebug() << "Graph" << name << "has been renamed or removed";
} else {
g = gi.value();
}
} }
if (g) { if (g) {
neworder.push_back(g); neworder.push_back(g);
g->setHeight(hght); g->setHeight(hght);
@ -3758,17 +3740,24 @@ bool gGraphView::LoadSettings(QString title,QString folderName)
g->setZoomY(static_cast<ZoomyScaling>(zoomy)); g->setZoomY(static_cast<ZoomyScaling>(zoomy));
g->setPinned(pinned); g->setPinned(pinned);
if (gvversion >= 4) { if (layertype == LT_LineChart) {
if (layertype == LT_LineChart) { gLineChart * lc = dynamic_cast<gLineChart *>(findLayer(g, LT_LineChart));
gLineChart * lc = dynamic_cast<gLineChart *>(findLayer(g, LT_LineChart)); if (lc) {
if (lc) { hashMerge(lc->m_flags_enabled, flags_enabled);
hashMerge(lc->m_flags_enabled, flags_enabled); hashMerge(lc->m_enabled, plots_enabled);
hashMerge(lc->m_enabled, plots_enabled); hashMerge(lc->m_dot_enabled, dot_enabled);
hashMerge(lc->m_dot_enabled, dot_enabled);
// the following check forces the flowRate graph to have a Zero dotted line enabled when the the current version changes from 4 to 5
// still allows the end user user to to remove the zero dotted line.
// currently this would be executed on each graphview version (gvVersion) change
// could be changed.
if (version!=gvversion ) {
if (lc->code()==CPAP_FlowRate) {
lc->m_dot_enabled[lc->code()][Calc_Zero] = true;
}
} }
} }
} }
} }
} }