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("%1 |
").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 += ""+tr("Unable to display Pie Chart on this system")+" |
\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+="
\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("%3 %5 | \n")
+ htmlLeftAHI+=QString("%3 %5 | \n")
.arg("#F88017").arg(COLOR_Text.name()).arg(ahiname).arg(schema::channel[ahichan].fullname()).arg(ahi,0,'f',2);
} else {
- html+=QString("%2 | \n")
+ htmlLeftAHI+=QString("%2 | \n")
.arg("#F88017").arg(tr("BRICK! :("));
}
- html+="
\n";
- html+="
\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("%3 | %4 |
\n")
+ htmlLeftIndices+=QString("%3 | %4 |
")
.arg(chan.defaultColor().name()).arg(altcolor.name()).arg(chan.fullname()).arg(data).arg(code);
}
- html+="
";
+ 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("%1 |
").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 += ""+tr("Unable to display Pie Chart on this system")+" |
\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+="
\n";
- html+="
\n";
-
- } else {
- html+="\n";
+ } else { // No hours
+ htmlLeftNoHours+="\n";
if (!isBrick) {
- html+=" |
\n";
+ htmlLeftNoHours+=" |
\n";
if (day->size()>0) {
- html+=""+tr("Sessions all off!")+" |
";
- html+=" |
";
- html+=""+tr("Sessions exist for this day but are switched off.")+" |
\n";
+ htmlLeftNoHours+=""+tr("Sessions all off!")+" |
";
+ htmlLeftNoHours+=" |
";
+ htmlLeftNoHours+=""+tr("Sessions exist for this day but are switched off.")+" |
\n";
GraphView->setEmptyText(STR_Empty_NoSessions);
} else {
- html+=""+tr("Impossibly short session")+" |
";
- html+=""+tr("Zero hours??")+" |
\n";
+ htmlLeftNoHours+=""+tr("Impossibly short session")+" |
";
+ htmlLeftNoHours+=""+tr("Zero hours??")+" |
\n";
}
} else { // machine is a brick
- html+=""+tr("BRICK :(")+" |
";
- html+=""+tr("Sorry, this machine only provides compliance data.")+" |
\n";
- html+=""+tr("Complain to your Equipment Provider!")+" |
\n";
+ htmlLeftNoHours+=""+tr("BRICK :(")+" |
";
+ htmlLeftNoHours+=""+tr("Sorry, this machine only provides compliance data.")+" |
\n";
+ htmlLeftNoHours+=""+tr("Complain to your Equipment Provider!")+" |
\n";
}
- html+=" |
\n";
- html+="
\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+=""+tr("\"Nothing's here!\"")+" |
";
- html+=" |
";
- html+=" |
";
- html+=""+tr("No data is available for this day.")+" |
";
- html+=" |
";
- html+="
\n";
+ htmlLeftStatistics ="";
+ htmlLeftStatistics+=" |
";
+ htmlLeftStatistics+=""+tr("\"Nothing's here!\"")+" |
";
+ htmlLeftStatistics+=" |
";
+ htmlLeftStatistics+=" |
";
+ htmlLeftStatistics+=""+tr("No data is available for this day.")+" |
";
+ htmlLeftStatistics+=" |
";
+ htmlLeftStatistics+="
\n";
}
}
if (day) {
- html+=getOximeterInformation(day);
- html+=getMachineSettings(day);
- html+=getSessionInformation(day);
+ htmlLeftOximeter = getOximeterInformation(day);
+ htmlLeftMachineSettings = getMachineSettings(day);
+ htmlLeftSessionInfo= getSessionInformation(day);
}
- html+="";
+ htmlLeftFooter ="