MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / buildHtml

Method buildHtml

app/src/Sessions/HtmlReport.cpp:259–299  ·  view source on GitHub ↗

* @brief Loads the template + stylesheet + runtime + Chart.js and expands every ``{{PLACEHOLDER}}`` * with the concrete value. */

Source from the content-addressed store, hash-verified

257 * with the concrete value.
258 */
259QString Sessions::HtmlReport::buildHtml() const
260{
261 QString html = readResource(QStringLiteral(":/templates/reports/session-report.html"));
262 const QString css = readResource(QStringLiteral(":/templates/reports/session-report.css"));
263 const QString js = readResource(QStringLiteral(":/templates/reports/session-report.js"));
264 const QString chartJs = readResource(QStringLiteral(":/chartjs/chart.umd.min.js"));
265 const QString brandSvg = readResource(QStringLiteral(":/logo/icon.svg"));
266
267 if (html.isEmpty() || css.isEmpty() || js.isEmpty() || chartJs.isEmpty())
268 return QString();
269
270 const QString coverHtml = m_opts.includeCover ? buildCoverSection() : QString();
271 const QString metadataHtml = m_opts.includeMetadata ? buildMetadataSection() : QString();
272 const QString summaryHtml = m_opts.includeStats ? buildSummarySection() : QString();
273 const QString chartsHtml =
274 (m_opts.includeCharts && !m_series.empty()) ? buildChartsSection() : QString();
275
276 html.replace(QStringLiteral("{{CHART_JS}}"), chartJs);
277 html.replace(QStringLiteral("{{REPORT_CSS}}"), css);
278 html.replace(QStringLiteral("{{REPORT_JS}}"), js);
279 html.replace(QStringLiteral("{{BRAND_ICON_SVG}}"), brandSvg);
280 html.replace(
281 QStringLiteral("{{DOCUMENT_TITLE}}"),
282 escapeHtml(m_opts.documentTitle.isEmpty() ? tr("Session Report") : m_opts.documentTitle));
283 html.replace(QStringLiteral("{{COVER_SECTION}}"), coverHtml);
284 html.replace(QStringLiteral("{{METADATA_SECTION}}"), metadataHtml);
285 html.replace(QStringLiteral("{{SUMMARY_SECTION}}"), summaryHtml);
286 html.replace(QStringLiteral("{{CHARTS_SECTION}}"), chartsHtml);
287 html.replace(QStringLiteral("{{REPORT_DATA_JSON}}"), buildReportDataJson());
288
289 html.replace(QStringLiteral("{{PAGE_SIZE_CSS}}"), pageSizeCssValue());
290 html.replace(QStringLiteral("{{PRINT_FOOTER_LEFT}}"), buildPrintFooterLeft());
291 html.replace(QStringLiteral("{{PRINT_FOOTER_RIGHT}}"), buildPrintFooterRight());
292
293 const auto chartMm = chartPagePrintableSize();
294 html.replace(QStringLiteral("{{CHART_PAGE_WIDTH_MM}}"), QString::number(chartMm.width(), 'f', 1));
295 html.replace(QStringLiteral("{{CHART_PAGE_HEIGHT_MM}}"),
296 QString::number(chartMm.height(), 'f', 1));
297
298 return html;
299}
300
301//--------------------------------------------------------------------------------------------------
302// Section: cover

Callers

nothing calls this directly

Calls 6

readResourceFunction · 0.85
escapeHtmlFunction · 0.85
isEmptyMethod · 0.80
emptyMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected