Re-order popup labels on Overview graph to match order of slices

Also change heading on AHI Overview to show same order
    Improve some variable names for ease of understanding code
This commit is contained in:
Guy Scharf 2020-08-02 20:24:56 -07:00
parent 32026446a5
commit 4f83c9b184
2 changed files with 23 additions and 18 deletions

View File

@ -223,11 +223,11 @@ void gLineOverlayBar::paint(QPainter &painter, gGraph &w, const QRegion &region)
painter.drawRect(rect); painter.drawRect(rect);
// Queue tooltip // Queue tooltip
QString lab2 = QString("%1").arg(schema::channel[m_code].fullname()); QString strEventTooltip = QString("%1").arg(schema::channel[m_code].fullname());
if (raw != 0) // Hide duration when it is zero if (raw != 0) // Hide duration when it is zero
lab2 += QString(" (%1)").arg(raw); strEventTooltip += QString(" (%1)").arg(raw);
w.ToolTip(lab2, x1 - 10, start_py + 24 + (3 * w.printScaleY()), TT_AlignRight, AppSetting->tooltipTimeout()); w.ToolTip(strEventTooltip, x1 - 10, start_py + 24 + (3 * w.printScaleY()), TT_AlignRight, AppSetting->tooltipTimeout());
painter.setPen(QPen(col,3)); painter.setPen(QPen(col,3));
} else { } else {

View File

@ -317,9 +317,10 @@ QString gSummaryChart::tooltipData(Day *, int idx)
{ {
QString txt; QString txt;
const auto & slices = cache[idx]; const auto & slices = cache[idx];
for (const auto & slice : slices) { int i = slices.size();
txt += QString("\n%1: %2").arg(slice.name).arg(float(slice.value), 0, 'f', 2); while (i > 0) {
i--;
txt += QString("\n%1: %2").arg(slices[i].name).arg(float(slices[i].value), 0, 'f', 2);
} }
return txt; return txt;
} }
@ -1240,33 +1241,35 @@ void gAHIChart::afterDraw(QPainter & /*painter */, gGraph &graph, QRectF rect)
QStringList txtlist; QStringList txtlist;
if (!skip) txtlist.append(QObject::tr("%1 %2 / %3 / %4").arg(STR_TR_AHI).arg(min_ahi, 0, 'f', 2).arg(med, 0, 'f', 2).arg(max_ahi, 0, 'f', 2)); if (!skip) txtlist.append(QObject::tr("%1 %2 / %3 / %4").arg(STR_TR_AHI).arg(min_ahi, 0, 'f', 2).arg(med, 0, 'f', 2).arg(max_ahi, 0, 'f', 2));
for (auto & calc : calcitems) { int i = calcitems.size();
ChannelID code = calc.code; while (i > 0) {
i--;
ChannelID code = calcitems[i].code;
schema::Channel & chan = schema::channel[code]; schema::Channel & chan = schema::channel[code];
float mid = 0; float mid = 0;
skip = true; skip = true;
switch (midcalc) { switch (midcalc) {
case 0: case 0:
if (calc.median_data.size() > 0) { if (calcitems[i].median_data.size() > 0) {
mid = median(calc.median_data.begin(), calc.median_data.end()); mid = median(calcitems[i].median_data.begin(), calcitems[i].median_data.end());
skip = false; skip = false;
} }
break; break;
case 1: case 1:
if (calc.divisor > 0) { if (calcitems[i].divisor > 0) {
mid = calc.wavg_sum / calc.divisor; mid = calcitems[i].wavg_sum / calcitems[i].divisor;
skip = false; skip = false;
} }
break; break;
case 2: case 2:
if (calc.cnt > 0) { if (calcitems[i].cnt > 0) {
mid = calc.avg_sum / calc.cnt; mid = calcitems[i].avg_sum / calcitems[i].cnt;
skip = false; skip = false;
} }
break; break;
} }
if (!skip) txtlist.append(QString("%1 %2 / %3 / %4").arg(chan.label()).arg(calc.min, 0, 'f', 2).arg(mid, 0, 'f', 2).arg(calc.max, 0, 'f', 2)); if (!skip) txtlist.append(QString("%1 %2 / %3 / %4").arg(chan.label()).arg(calcitems[i].min, 0, 'f', 2).arg(mid, 0, 'f', 2).arg(calcitems[i].max, 0, 'f', 2));
} }
QString txt = txtlist.join(", "); QString txt = txtlist.join(", ");
graph.renderText(txt, rect.left(), rect.top()-5*graph.printScaleY(), 0); graph.renderText(txt, rect.left(), rect.top()-5*graph.printScaleY(), 0);
@ -1294,9 +1297,11 @@ QString gAHIChart::tooltipData(Day *day, int idx)
float total = 0; float total = 0;
float hour = day->hours(m_machtype); float hour = day->hours(m_machtype);
QString txt; QString txt;
for (const auto & slice : slices) { int i = slices.size();
total += slice.value; while (i > 0) {
txt += QString("\n%1: %2").arg(slice.name).arg(float(slice.value) / hour, 0, 'f', 2); i--;
total += slices[i].value;
txt += QString("\n%1: %2").arg(slices[i].name).arg(float(slices[i].value) / hour, 0, 'f', 2);
} }
return QString("\n%1: %2").arg(STR_TR_AHI).arg(float(total) / hour,0,'f',2)+txt; return QString("\n%1: %2").arg(STR_TR_AHI).arg(float(total) / hour,0,'f',2)+txt;
} }