KonqSidebarPlugin: Get a pointer to the active KHTMLPart
Cristian Boya de Groot
cristianbdg at telefonica.net
Wed Jul 20 20:18:41 BST 2005
First of all, I would like to thank Dawit Alemayehu for his answer to my
previous question about a site-specific referer. It worked perfectly!
Second, I was hoping someone could answer this totally different question.
I'm trying program a Konqueror Sidebar plugin that needs to get a list of the
images, links, etc. of the page that Konqueror is showing.
I had this working by using the DOM::HTMLDocument of the current page, which I
got using the following awkward method:
From the KonqSidebarPlugin:
1. find the KonqMainWindow by doing
QObject* konqmainwindow = parent->parent()->parent()->parent()->parent();
2. loop through konqmainwindow->children() until finding a KonqViewManager
3. KHTMLPart* page = (KHTMLPart*) konqviewmanager->activePart();
4. DOM::HTMLDocument doc = page->htmlDocument();
5. Use the doc to get links, images, etc.
But this stopped working several kde-versions ago (fortunately, because it was
pretty awful). I've been searching among the functions of the involved
classes for another way, but didn't find one. So here's my main question:
Is there a *clean way (not like I did) to get a pointer to the currently
active KHTMLPart from the Sidebar?
If not, wouldn't this be a logic thing to have? I mean, the sidebar should be
able to interact with the page, right?
Thanks in advance for your attention,
Chris
More information about the kfm-devel
mailing list