D8211: KDevelop/Documentation : support using QTextBrowser (WIP/PoC)

René J.V. Bertin noreply at phabricator.kde.org
Mon Oct 9 08:30:45 UTC 2017

rjvbb added a comment.

  Thanks for speaking my mind (too) stronger than I dared :)
  Here's what I meant with collaborative: maybe those of us who'd like to see this get in could try the patch for a while, see what works, what doesn't, and what can be improved? Note that I've focussed on the QtHelp documentation, have done only a few quick checks of CMake docs and didn't try the manpage plugin at all as yet.
  I see that the RB ticket mentions how the patch under review doesn't allow to follow links in QtHelp docs. Figuring out how to do that (without ending up in an unending reload loop) was what took me the most time, and is why I'm deriving QTextBrowser. The real tricky thing is that, ideally, StandardDocumentationView would need direct access to QHelp* APIs to fetch the content of `qthelp:` URLs.
  Basically, you need to override `QTextBrowser::loadResource(type,url)` with a method that can invoke `QHelpEngine::fileData(url)` and return that content. I am currently working around that by using a new `StandardDocumentView::load(url,content)` method in the QtHelp plugin. I think that's safe because (I think) we shouldn't ever be in a situation where we cannot do that. The obvious other approach would be to provide StandardDocumentationView with a callback to a QtHelpDocumentation method which does the work, for instance a closer clone of the Assistant's
    QVariant HelpViewer::loadResource(int type, const QUrl &name)
        QByteArray ba;
        if (type < 4) {
            const QUrl url = HelpEngineWrapper::instance().findFile(name);
            ba = HelpEngineWrapper::instance().fileData(url);
            if (url.toString().endsWith(QLatin1String(".svg"), Qt::CaseInsensitive)) {
                QImage image;
                image.loadFromData(ba, "svg");
                if (!image.isNull())
                    return image;
        return ba;
  (Having support for some types of images could be nice, but is it useful?)

  R32 KDevelop


To: rjvbb, #kdevelop
Cc: flherne, arichardson, apol, kdevelop-devel, geetamc, Pilzschaf, akshaydeo, surgenight, arrowdodger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20171009/e4cf4897/attachment.html>

More information about the KDevelop-devel mailing list