Mercurial > octave
changeset 26144:494452db0477
doc browser: append anchor from url to history titles (bug #54938)
* documentation.cc (update_history): extract anchor from url, replace
encodings by normal characters and append it to the title before
adding the title to the history menus
author | Torsten <mttl@mailbox.org> |
---|---|
date | Tue, 27 Nov 2018 22:04:25 +0100 |
parents | c7f845bf4fec |
children | 64b972120ec3 |
files | libgui/src/documentation.cc |
diffstat | 1 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/documentation.cc Tue Nov 27 22:04:22 2018 +0100 +++ b/libgui/src/documentation.cc Tue Nov 27 22:04:25 2018 +0100 @@ -721,6 +721,35 @@ QString title = m_doc_browser->historyTitle (prev_next*(i+1)); title.remove (QRegExp ("\\s*\\(*GNU Octave \\(version [^\\)]*\\)[: \\)]*")); + // Sinve the title only contains the section name and not the + // specific anchor, extract the latter from the url and append + // it to the title + QString url = m_doc_browser->historyUrl (prev_next*(i+1)).toString (QUrl::FullyEncoded); + if (url.contains ('#')) + { + // Get the anchor from the url + QString anchor = url.split ('#').last (); + + // Remove internal string parts + anchor.remove (QRegExp ("^index-")); + anchor.remove (QRegExp ("^SEC_")); + anchor.remove (QRegExp ("^XREF")); + anchor.remove ("Concept-Index_cp_letter-"); + anchor.replace ("-"," "); + + // replace encoded special chars by there unencoded versions + QRegExp rx = QRegExp ("_00([0-7][0-9a-f])"); + int pos = 0; + while ((pos = rx.indexIn(anchor, pos)) != -1) + { + anchor.replace ("_00"+rx.cap (1), QChar (rx.cap (1).toInt (nullptr,16))); + pos += rx.matchedLength(); + } + + if (title != anchor) + title = title + ": " + anchor; + } + if (i == 0) a->setText (title); // set tool tip for prev/next buttons