55 section.
title = sTitle;
56 section.
htmlContent =
"<p>" + sContent.toHtmlEscaped() +
"</p>";
57 m_sections.append(section);
63 const QStringList& headers,
64 const QList<QStringList>& rows)
66 QString html =
"<table>\n<thead><tr>\n";
67 for (
const auto& h : headers) {
68 html +=
" <th>" + h.toHtmlEscaped() +
"</th>\n";
70 html +=
"</tr></thead>\n<tbody>\n";
72 for (
const auto& row : rows) {
74 for (
const auto& cell : row) {
75 html +=
" <td>" + cell.toHtmlEscaped() +
"</td>\n";
79 html +=
"</tbody>\n</table>";
82 section.
title = sTitle;
84 m_sections.append(section);
90 const QList<QPair<QString, QString>>& pairs)
92 QString html =
"<dl>\n";
93 for (
const auto& pair : pairs) {
94 html +=
" <dt>" + pair.first.toHtmlEscaped() +
"</dt>\n";
95 html +=
" <dd>" + pair.second.toHtmlEscaped() +
"</dd>\n";
100 section.
title = sTitle;
102 m_sections.append(section);
110 section.
title = sTitle;
111 section.
htmlContent =
"<pre><code>" + sCode.toHtmlEscaped() +
"</code></pre>";
112 m_sections.append(section);
120 html +=
"<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n";
121 html +=
"<meta charset=\"UTF-8\">\n";
122 html +=
"<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n";
123 html +=
"<title>" + m_sTitle.toHtmlEscaped() +
"</title>\n";
125 html +=
"body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; ";
126 html +=
"max-width: 960px; margin: 0 auto; padding: 20px; color: #333; }\n";
127 html +=
"h1 { color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; }\n";
128 html +=
"h2 { color: #2980b9; margin-top: 30px; }\n";
129 html +=
"table { border-collapse: collapse; width: 100%; margin: 10px 0; }\n";
130 html +=
"th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }\n";
131 html +=
"th { background-color: #3498db; color: white; }\n";
132 html +=
"tr:nth-child(even) { background-color: #f2f2f2; }\n";
133 html +=
"dl { margin: 10px 0; }\n";
134 html +=
"dt { font-weight: bold; margin-top: 8px; }\n";
135 html +=
"dd { margin-left: 20px; color: #555; }\n";
136 html +=
"pre { background-color: #f8f8f8; border: 1px solid #ddd; padding: 12px; ";
137 html +=
"border-radius: 4px; overflow-x: auto; }\n";
138 html +=
"code { font-family: 'SF Mono', Menlo, Monaco, monospace; font-size: 0.9em; }\n";
139 html +=
".footer { margin-top: 40px; padding-top: 10px; border-top: 1px solid #ddd; ";
140 html +=
"color: #999; font-size: 0.85em; }\n";
141 html +=
"</style>\n</head>\n<body>\n";
143 html +=
"<h1>" + m_sTitle.toHtmlEscaped() +
"</h1>\n";
145 for (
const auto& section : m_sections) {
146 html +=
"<h2>" + section.title.toHtmlEscaped() +
"</h2>\n";
147 html += section.htmlContent +
"\n";
150 html +=
"<div class=\"footer\">\n";
151 html +=
"<p>Generated by MNE-CPP on " + QDateTime::currentDateTime().toString(Qt::ISODate) +
"</p>\n";
153 html +=
"</body>\n</html>\n";
163 if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
164 qWarning() <<
"[Report::save] Cannot open:" << sPath;
168 QTextStream out(&file);
HTML report builder — mne-cpp's equivalent of mne.Report for summarising analysis pipelines.
Shared utilities (I/O helpers, spectral analysis, layout management, warp algorithms).
A section in the report (title + HTML content).
Report(const QString &sTitle="MNE-CPP Report")
Construct a report with a title.
bool save(const QString &sPath) const
Save the report to an HTML file.
void addCode(const QString &sTitle, const QString &sCode)
Add a preformatted code block.
QString toHtml() const
Generate the full HTML string.
void addKeyValue(const QString &sTitle, const QList< QPair< QString, QString > > &pairs)
Add a key-value section.
void addText(const QString &sTitle, const QString &sContent)
Add a text section.
void addTable(const QString &sTitle, const QStringList &headers, const QList< QStringList > &rows)
Add a table section.