[education/rkward] rkward/windows: Wrap sections into divs to allow more control over the layout
Thomas Friedrichsmeier
null at kde.org
Wed Apr 20 14:02:40 BST 2022
Git commit 301e3afd77f126c039bd4de3b119299a7d5f7019 by Thomas Friedrichsmeier.
Committed on 19/04/2022 at 10:09.
Pushed by tfry into branch 'master'.
Wrap sections into divs to allow more control over the layout
M +13 -1 rkward/windows/rkhtmlwindow.cpp
M +2 -1 rkward/windows/rkhtmlwindow.h
https://invent.kde.org/education/rkward/commit/301e3afd77f126c039bd4de3b119299a7d5f7019
diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index 30fde668..b859a214 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -1090,12 +1090,14 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
if (!element.isNull ()) {
writeHTML (startSection ("summary", i18n ("Summary"), QString (), &anchors, &anchornames));
writeHTML (renderHelpFragment (element));
+ writeHTML(endSection());
}
element = help_xml_helper.getChildElement (help_doc_element, "usage", DL_INFO);
if (!element.isNull ()) {
writeHTML (startSection ("usage", i18n ("Usage"), QString (), &anchors, &anchornames));
writeHTML (renderHelpFragment (element));
+ writeHTML(endSection());
}
XMLChildList section_elements = help_xml_helper.getChildElements (help_doc_element, "section", DL_INFO);
@@ -1119,6 +1121,7 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
}
}
writeHTML (renderHelpFragment (*it));
+ writeHTML(endSection());
}
// the section "settings" is the most complicated, as the labels of the individual GUI items has to be fetched from the component description. Of course it is only meaningful for component help, and not rendered for top level help pages.
@@ -1143,6 +1146,7 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
help_xml_helper.displayError (&(*it), "Tag not allowed, here", DL_WARNING);
}
}
+ writeHTML(endSection());
}
}
@@ -1151,6 +1155,7 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
if (!element.isNull ()) {
writeHTML (startSection ("related", i18n ("Related functions and pages"), QString (), &anchors, &anchornames));
writeHTML (renderHelpFragment (element));
+ writeHTML(endSection());
}
// "technical" section
@@ -1158,6 +1163,7 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
if (!element.isNull ()) {
writeHTML (startSection ("technical", i18n ("Technical details"), QString (), &anchors, &anchornames));
writeHTML (renderHelpFragment (element));
+ writeHTML(endSection());
}
if (for_component) {
@@ -1166,6 +1172,7 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
if (!deps.isEmpty ()) {
writeHTML (startSection ("dependencies", i18n ("Dependencies"), QString (), &anchors, &anchornames));
writeHTML (RKComponentDependency::depsToHtml (deps));
+ writeHTML(endSection());
}
}
@@ -1179,6 +1186,7 @@ bool RKHelpRenderer::renderRKHelp (const QUrl &url, RKHTMLWindow* container) {
if (about.valid) {
writeHTML (startSection ("about", i18n ("About"), QString (), &anchors, &anchornames));
writeHTML (about.toHtml ());
+ writeHTML(endSection());
}
// create a navigation bar
@@ -1319,7 +1327,7 @@ RKComponentHandle *RKHelpRenderer::componentPathToHandle (const QString &path) {
}
QString RKHelpRenderer::startSection (const QString &name, const QString &title, const QString &shorttitle, QStringList *anchors, QStringList *anchor_names) {
- QString ret = "<a name=\"" + name + "\">";
+ QString ret = "<div id=\"" + name + "\"><a name=\"" + name + "\">";
ret.append ("<h2>" + title + "</h2>\n");
anchors->append (name);
if (!shorttitle.isNull ()) anchor_names->append (shorttitle);
@@ -1327,6 +1335,10 @@ QString RKHelpRenderer::startSection (const QString &name, const QString &title,
return (ret);
}
+QString RKHelpRenderer::endSection() {
+ return("</div>\n");
+}
+
void RKHelpRenderer::writeHTML (const QString& string) {
RK_TRACE (APP);
diff --git a/rkward/windows/rkhtmlwindow.h b/rkward/windows/rkhtmlwindow.h
index 58d65424..297cb300 100644
--- a/rkward/windows/rkhtmlwindow.h
+++ b/rkward/windows/rkhtmlwindow.h
@@ -190,7 +190,8 @@ private:
QString prepareHelpLink (const QString &href, const QString &text);
QString componentPathToId (const QString &path);
RKComponentHandle *componentPathToHandle (const QString &path);
- QString startSection (const QString &name, const QString &title, const QString &shorttitle, QStringList *anchors, QStringList *anchor_names);
+ QString startSection(const QString &name, const QString &title, const QString &shorttitle, QStringList *anchors, QStringList *anchor_names);
+ QString endSection();
QIODevice *device;
void writeHTML (const QString &string);
More information about the rkward-tracker
mailing list