| 171 | } |
| 172 | |
| 173 | void OutputWidget::addSolution(const QVariantMap& output, const QStringList& order, qint64 time) |
| 174 | { |
| 175 | TextLayoutLock lock(this); |
| 176 | QTextCursor cursor = nextInsertAt(); |
| 177 | if (!_checkerOutput.isEmpty()) { |
| 178 | cursor.insertText("% Solution checker report:\n", _commentCharFormat); |
| 179 | for (auto& it : _checkerOutput) { |
| 180 | auto section = it.first; |
| 181 | if (section == "raw" || it.second.toString().isEmpty()) { |
| 182 | continue; |
| 183 | } |
| 184 | addSection(section); |
| 185 | QTextBlockFormat format; |
| 186 | format.setProperty(Property::Section, section); |
| 187 | cursor.setBlockFormat(format); |
| 188 | cursor.block().setVisible(_sections[section]); |
| 189 | if (section == "html" || section.endsWith("_html")) { |
| 190 | addHtmlToSection(section, it.second.toString()); |
| 191 | } else { |
| 192 | auto lines = it.second.toString().split("\n"); |
| 193 | if (lines.last().isEmpty()) { |
| 194 | lines.pop_back(); |
| 195 | } |
| 196 | bool first = true; |
| 197 | for (auto& line : lines) { |
| 198 | addTextToSection(section, (first ? "% " : "\n% ") + line, _commentCharFormat); |
| 199 | first = false; |
| 200 | } |
| 201 | } |
| 202 | if (!cursor.block().text().isEmpty()) { |
| 203 | cursor.insertBlock(); |
| 204 | } |
| 205 | } |
| 206 | _checkerOutput.clear(); |
| 207 | } |
| 208 | |
| 209 | for (auto& section : order) { |
| 210 | if (section == "raw" || output[section].toString().isEmpty()) { |
| 211 | continue; |
| 212 | } |
| 213 | addSection(section); |
| 214 | QTextBlockFormat format; |
| 215 | format.setProperty(Property::Section, section); |
| 216 | cursor.setBlockFormat(format); |
| 217 | cursor.block().setVisible(_sections[section]); |
| 218 | if (section == "html" || section.endsWith("_html")) { |
| 219 | addHtmlToSection(section, output[section].toString()); |
| 220 | } else { |
| 221 | addTextToSection(section, output[section].toString()); |
| 222 | } |
| 223 | if (!cursor.block().text().isEmpty()) { |
| 224 | cursor.insertBlock(); |
| 225 | } |
| 226 | } |
| 227 | if (time != -1) { |
| 228 | QTextBlockFormat f; |
| 229 | f.setProperty(Property::MessageType, "Timing"); |
| 230 | cursor.setBlockFormat(f); |
nothing calls this directly
no test coverage detected