diff --git a/oscar/daily.cpp b/oscar/daily.cpp index 3935d78a..7aad0aac 100644 --- a/oscar/daily.cpp +++ b/oscar/daily.cpp @@ -42,6 +42,20 @@ extern MainWindow * mainwin; +QString htmlLeftHeader; +QString htmlLeftAHI; +QString htmlLeftMachineInfo; +QString htmlLeftSleepTime; +QString htmlLeftIndices; +QString htmlLeftPieChart = ""; +QString htmlLeftNoHours = ""; +QString htmlLeftStatistics; +QString htmlLeftOximeter; +QString htmlLeftMachineSettings; +QString htmlLeftSessionInfo; +QString htmlLeftFooter; + + // This was Sean Stangl's idea.. but I couldn't apply that patch. inline QString channelInfo(ChannelID code) { return schema::channel[code].fullname()+"\n"+schema::channel[code].description()+"\n("+schema::channel[code].units()+")"; @@ -579,12 +593,18 @@ void Daily::hideSpaceHogs() if (AppSetting->calendarVisible()) { ui->calendarFrame->setVisible(false); } + if (AppSetting->showPieChart()) { + webView->setHtml(getLeftSidebar(false)); + } } void Daily::showSpaceHogs() { if (AppSetting->calendarVisible()) { ui->calendarFrame->setVisible(true); } + if (AppSetting->showPieChart()) { + webView->setHtml(getLeftSidebar(true)); + } } void Daily::on_calendar_currentPageChanged(int year, int month) @@ -1307,6 +1327,63 @@ QString Daily::getSleepTime(Day * day) return html; } +QString Daily::getPieChart (float values, Day * day) { + qDebug() << "Daily:getPieChart, values" << values; + QString html = ""; + if (values > 0) { +// html += ""; + html += QString("").arg(tr("Event Breakdown")); + eventBreakdownPie()->setShowTitle(false); + + int w=155; + int h=155; + QPixmap pixmap=eventBreakdownPie()->renderPixmap(w,h,false); + if (!pixmap.isNull()) { + QByteArray byteArray; + QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray + buffer.open(QIODevice::WriteOnly); + pixmap.save(&buffer, "PNG"); + html += "\n"; + } else { + html += "\n"; + } + } else if ( day->channelHasData(CPAP_Obstructive) + || day->channelHasData(CPAP_Hypopnea) + || day->channelHasData(CPAP_ClearAirway) + || day->channelHasData(CPAP_RERA) + || day->channelHasData(CPAP_Apnea) + || day->channelHasData(CPAP_FlowLimit) + || day->channelHasData(CPAP_SensAwake) + ) { + html += "\n"; + } + html+="
 
%1
"+tr("Unable to display Pie Chart on this system")+"
\n"; + html+="
\n"; + + return html; +} + +// honorPieChart true - show pie chart if it is enabled. False, do not show pie chart +QString Daily::getLeftSidebar (bool honorPieChart) { + QString html = htmlLeftHeader + + htmlLeftAHI + + htmlLeftMachineInfo + + htmlLeftSleepTime + + htmlLeftIndices; + // Include pie chart if wanted and enabled. + if (honorPieChart && AppSetting->showPieChart()) + html += htmlLeftPieChart; + + html += htmlLeftNoHours + + htmlLeftStatistics + + htmlLeftOximeter + + htmlLeftMachineSettings + + htmlLeftSessionInfo + + htmlLeftFooter; + + return html; +} + QVariant MyTextBrowser::loadResource(int type, const QUrl &url) { if (type == QTextDocument::ImageResource && url.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0) { @@ -1355,7 +1432,19 @@ void Daily::Load(QDate date) lastcpapday=day; - QString html="" + // Clear the components of the left sidebar prior to recreating them + htmlLeftAHI.clear(); + htmlLeftMachineInfo.clear(); + htmlLeftSleepTime.clear(); + htmlLeftIndices.clear(); + htmlLeftPieChart.clear(); + htmlLeftNoHours.clear(); + htmlLeftStatistics.clear(); + htmlLeftOximeter.clear(); + htmlLeftMachineSettings.clear(); + htmlLeftSessionInfo.clear(); + + htmlLeftHeader = "" "" ""; @@ -1420,8 +1509,8 @@ void Daily::Load(QDate date) ahi/=hours; if (hours>0) { - html+="\n"; - html+=""; + htmlLeftAHI="
\n"; + htmlLeftAHI+=""; if (!isBrick) { ChannelID ahichan=CPAP_AHI; QString ahiname=STR_TR_AHI; @@ -1429,19 +1518,20 @@ void Daily::Load(QDate date) ahichan=CPAP_RDI; ahiname=STR_TR_RDI; } - html+=QString("\n") + htmlLeftAHI+=QString("\n") .arg("#F88017").arg(COLOR_Text.name()).arg(ahiname).arg(schema::channel[ahichan].fullname()).arg(ahi,0,'f',2); } else { - html+=QString("\n") + htmlLeftAHI+=QString("\n") .arg("#F88017").arg(tr("BRICK! :(")); } - html+="\n"; - html+="

%3

  %5

%3

  %5
%2%2
\n"; - html+=getCPAPInformation(day); - html+=getSleepTime(day); + htmlLeftAHI+="\n"; + htmlLeftAHI+="\n"; - html+="\n"; + htmlLeftMachineInfo = getCPAPInformation(day); + htmlLeftSleepTime = getSleepTime(day); + + htmlLeftIndices = "
\n"; quint32 zchans = schema::SPAN | schema::FLAG; bool show_minors = true; @@ -1469,97 +1559,66 @@ void Daily::Load(QDate date) // than the duration of timed breaths per hour. values[code] = val; QColor altcolor = (brightness(chan.defaultColor()) < 0.3) ? Qt::white : Qt::black; // pick a contrasting color - html+=QString("\n") + htmlLeftIndices+=QString("") .arg(chan.defaultColor().name()).arg(altcolor.name()).arg(chan.fullname()).arg(data).arg(code); } - html+="
%3%4
%3%4
"; + htmlLeftIndices+="
"; - html+="\n"; - // Show Event Breakdown pie chart - if ((hours > 0) && AppSetting->showPieChart()) { // AHI Pie Chart - if ((values[CPAP_Obstructive] + values[CPAP_Hypopnea] + values[CPAP_ClearAirway] + values[CPAP_Apnea] + values[CPAP_RERA] + values[CPAP_FlowLimit] + values[CPAP_SensAwake])>0) { - html+=""; - html+=QString("").arg(tr("Event Breakdown")); - eventBreakdownPie()->setShowTitle(false); + htmlLeftPieChart = getPieChart((values[CPAP_Obstructive] + values[CPAP_Hypopnea] + + values[CPAP_ClearAirway] + values[CPAP_Apnea] + values[CPAP_RERA] + + values[CPAP_FlowLimit] + values[CPAP_SensAwake]), day); - int w=155; - int h=155; - QPixmap pixmap=eventBreakdownPie()->renderPixmap(w,h,false); - if (!pixmap.isNull()) { - QByteArray byteArray; - QBuffer buffer(&byteArray); // use buffer to store pixmap into byteArray - buffer.open(QIODevice::WriteOnly); - pixmap.save(&buffer, "PNG"); - html += "\n"; - } else { - html += "\n"; - } - } else if (day->channelHasData(CPAP_Obstructive) - || day->channelHasData(CPAP_Hypopnea) - || day->channelHasData(CPAP_ClearAirway) - || day->channelHasData(CPAP_RERA) - || day->channelHasData(CPAP_Apnea) - || day->channelHasData(CPAP_FlowLimit) - || day->channelHasData(CPAP_SensAwake) - ) { - html += "\n"; - } - } - - html+="
 
%1
"+tr("Unable to display Pie Chart on this system")+"
\n"; - html+="
\n"; - - } else { - html+="\n"; + } else { // No hours + htmlLeftNoHours+="
\n"; if (!isBrick) { - html+="\n"; + htmlLeftNoHours+="\n"; if (day->size()>0) { - html+=""; - html+=""; - html+="\n"; + htmlLeftNoHours+=""; + htmlLeftNoHours+=""; + htmlLeftNoHours+="\n"; GraphView->setEmptyText(STR_Empty_NoSessions); } else { - html+=""; - html+="\n"; + htmlLeftNoHours+=""; + htmlLeftNoHours+="\n"; } } else { // machine is a brick - html+=""; - html+="\n"; - html+="\n"; + htmlLeftNoHours+=""; + htmlLeftNoHours+="\n"; + htmlLeftNoHours+="\n"; } - html+="\n"; - html+="
 
 
"+tr("Sessions all off!")+"
"+tr("Sessions exist for this day but are switched off.")+"
"+tr("Sessions all off!")+"
"+tr("Sessions exist for this day but are switched off.")+"

"+tr("Impossibly short session")+"

"+tr("Zero hours??")+"

"+tr("Impossibly short session")+"

"+tr("Zero hours??")+"

"+tr("BRICK :(")+"

"+tr("Sorry, this machine only provides compliance data.")+"
"+tr("Complain to your Equipment Provider!")+"

"+tr("BRICK :(")+"

"+tr("Sorry, this machine only provides compliance data.")+"
"+tr("Complain to your Equipment Provider!")+"
 
\n"; + htmlLeftNoHours+=" \n"; + htmlLeftNoHours+="\n"; } } // if (!CPAP) - else html+=getSleepTime(day); + else htmlLeftSleepTime = getSleepTime(day); if ((cpap && !isBrick && (day->hours()>0)) || oxi || posit) { - html+=getStatisticsInfo(day); + htmlLeftStatistics = getStatisticsInfo(day); } else { if (cpap && day->hours(MT_CPAP)<0.0000001) { } else if (!isBrick) { - html+=""; - html+=""; - html+=""; - html+=""; - html+=""; - html+=""; - html+=""; - html+="
"+tr("\"Nothing's here!\"")+"
"+tr("No data is available for this day.")+"
\n"; + htmlLeftStatistics =""; + htmlLeftStatistics+=""; + htmlLeftStatistics+=""; + htmlLeftStatistics+=""; + htmlLeftStatistics+=""; + htmlLeftStatistics+=""; + htmlLeftStatistics+=""; + htmlLeftStatistics+="
"+tr("\"Nothing's here!\"")+"
"+tr("No data is available for this day.")+"
\n"; } } if (day) { - html+=getOximeterInformation(day); - html+=getMachineSettings(day); - html+=getSessionInformation(day); + htmlLeftOximeter = getOximeterInformation(day); + htmlLeftMachineSettings = getMachineSettings(day); + htmlLeftSessionInfo= getSessionInformation(day); } - html+=""; + htmlLeftFooter =""; QColor cols[]={ COLOR_Gold, @@ -1592,7 +1651,7 @@ void Daily::Load(QDate date) } #endif - webView->setHtml(html); + webView->setHtml(getLeftSidebar(true)); ui->JournalNotes->clear(); diff --git a/oscar/daily.h b/oscar/daily.h index 7b0a9254..787a322a 100644 --- a/oscar/daily.h +++ b/oscar/daily.h @@ -296,13 +296,17 @@ private: void updateCube(); + QString getLeftAHI (Day * day); QString getSessionInformation(Day *); QString getMachineSettings(Day *); QString getStatisticsInfo(Day *); QString getCPAPInformation(Day *); QString getOximeterInformation(Day *); QString getEventBreakdown(Day *); + QString getPieChart(float values, Day *); + QString getIndicesAndPie(Day *, float hours, bool isBrick); QString getSleepTime(Day *); + QString getLeftSidebar (bool honorPieChart); QHash graphlist; diff --git a/oscar/mainwindow.ui b/oscar/mainwindow.ui index 5062cf99..3e20f998 100644 --- a/oscar/mainwindow.ui +++ b/oscar/mainwindow.ui @@ -3135,7 +3135,7 @@ p, li { white-space: pre-wrap; } true - Toggle &Line Cursor + Show &Line Cursor Ctrl+L @@ -3221,7 +3221,7 @@ p, li { white-space: pre-wrap; } false - Toggle &Pie Chart + Show &Pie Chart Show Pie Chart on Daily page