From 310daae53926628f80c08e4415b94b90ad525c8f Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 18 Dec 2017 13:05:20 +0100 Subject: preserve HTML heading level in QTextBlockFormat; demonstrate in example When reading an HTML file with

for example, we still set the font size as before (that's how it always was done), but now it remembers that it came from an H1 tag, so it writes

... rather than

... This will help with the upcoming Markdown format, where heading level is saved but the font is not. Now the style combobox in examples/widgets/richtext/textedit can set list item type, heading type or "standard" formatting, and also shows the current formatting of the line that has the cursor. It was always a shortcoming in this example that it only allowed setting the current line's block format but had no feedback to show the current format. Change-Id: I0a7849b74f23fea84d3375c487c3a6b9f43240c1 Reviewed-by: Lars Knoll --- src/gui/text/qtextdocument.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/gui/text/qtextdocument.cpp') diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp index d95932f4db..e58cd02af5 100644 --- a/src/gui/text/qtextdocument.cpp +++ b/src/gui/text/qtextdocument.cpp @@ -2906,7 +2906,11 @@ void QTextHtmlExporter::emitBlock(const QTextBlock &block) html += QLatin1Char('>'); html += QLatin1String(" 0 && headingLevel <= 6) + html += QLatin1String(""); else if (list) html += QLatin1String(""); - else - html += QLatin1String("

"); + else { + int headingLevel = blockFormat.headingLevel(); + if (headingLevel > 0 && headingLevel <= 6) + html += QLatin1String("'); + else + html += QLatin1String("

"); + } if (list) { if (list->itemNumber(block) == list->count() - 1) { // last item? close list -- cgit v1.2.3