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

Method render

app/src/Sessions/HtmlReport.cpp:192–249  ·  view source on GitHub ↗

* @brief Orchestrates the render. */

Source from the content-addressed store, hash-verified

190 * @brief Orchestrates the render.
191 */
192void Sessions::HtmlReport::render(const ReportData& data,
193 std::vector<DatasetSeries> series,
194 const HtmlReportOptions& opts)
195{
196 if (!data.valid || opts.outputPath.isEmpty()) {
197 Q_EMIT finished(QString(), false);
198 return;
199 }
200
201 m_data = data;
202 m_series = std::move(series);
203 m_opts = opts;
204
205# ifndef SERIAL_STUDIO_WITH_WEBENGINE
206 m_opts.format = HtmlReportOptions::Format::Html;
207# endif
208
209 Q_EMIT progress(tr("Assembling report…"), 0.10);
210
211 m_htmlCache = buildHtml();
212 if (m_htmlCache.isEmpty()) {
213 Q_EMIT finished(QString(), false);
214 return;
215 }
216
217 Q_EMIT progress(tr("Writing output…"), 0.30);
218
219 const QFileInfo outInfo(opts.outputPath);
220 const QString stem = outInfo.completeBaseName();
221 const QString dir = outInfo.absolutePath();
222 m_pdfPath = opts.outputPath.endsWith(".pdf", Qt::CaseInsensitive)
223 ? opts.outputPath
224 : QStringLiteral("%1/%2.pdf").arg(dir, stem);
225 m_htmlPath = opts.outputPath.endsWith(".html", Qt::CaseInsensitive)
226 ? opts.outputPath
227 : QStringLiteral("%1/%2.html").arg(dir, stem);
228
229 bool htmlOk = true;
230 if (m_opts.format == HtmlReportOptions::Format::Html
231 || m_opts.format == HtmlReportOptions::Format::Both) {
232 writeHtmlArtifact(m_htmlPath, m_htmlCache, htmlOk);
233 m_htmlWritten = htmlOk;
234 }
235
236 if (m_opts.format == HtmlReportOptions::Format::Html) {
237 Q_EMIT finished(m_htmlPath, htmlOk);
238 return;
239 }
240
241# ifdef SERIAL_STUDIO_WITH_WEBENGINE
242 if (!htmlOk && m_opts.format == HtmlReportOptions::Format::Both) {
243 Q_EMIT finished(m_htmlPath, false);
244 return;
245 }
246
247 startPdfRender(m_htmlCache, m_pdfPath);
248# endif
249}

Callers 3

renderColorizedSvgMethod · 0.45
requestImageMethod · 0.45

Calls 1

isEmptyMethod · 0.80

Tested by

no test coverage detected