back and forward with history in a kpart with browserextension

David Faure faure at kde.org
Fri Dec 22 21:38:19 GMT 2006


On Friday 22 December 2006 08:24, Jos van den Oever wrote:
> Hi all,
> 
> I'm trying to write a kpart that uses the browser extension for doing
> file searches.

Discussed on irc, debugged, and fixed.

bool
ServiceTestPart::openURL(const KURL& url) {
    kdDebug() << "ServiceTestPart::openURL " << url << endl;
    m_url = url;
    widget->openFile(url.path());
    emit completed(); // very important!!
    emit setWindowCaption(url.prettyURL());
    return true;
}

void
ServiceTestPart::queryUpdated() {
    kdDebug() << "queryUpdated" << endl;
    KURL newurl = "kiotest:"+widget->getQuery();
    if (newurl != m_url) {
        KParts::URLArgs args;
        args.serviceType = "uri/kiotest";
        browserextension->openURLRequest(newurl, args);
    }
}

Plus adding an Exec line to the service .desktop file so that konq (kfmclient) is associated
with this mimetype. A little bit hackish, but otherwise konq offers to save when opening a url,
as it does over http.

KDE4 TODO: turn URLArgs::setForcesNewWindow() into a tristate enum?
 (force new window, force embed, unset)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kfm-devel mailing list