You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, March 31st 2005, 6:15am

question about KHTMLPart

hi all,
I am using KHTMLPart to display rich text chatting messages. But I cannot figure out how to enable copy and paste functionalities(like Ctrl-v, Ctrl+v or using mouse popup menu). should I implement by myself or there is some setting in this class?

Can anyone help me? Thanks in advance.

yunfan

Posts: 15

Location: Padova, Italy

Occupation: Student

  • Send private message

2

Thursday, March 31st 2005, 10:35am

AFAIK, you have to implement that by hand.

All the help you can get from KHTML part is some events for mouse clicks, and from Kapp you can have the standard actions (cut, paste and copy are there)
--
Antonio

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

3

Thursday, March 31st 2005, 3:03pm

See KHTMLPart::browserExtension

Cheers,
_
Qt/KDE Developer
Debian User

4

Friday, April 1st 2005, 2:48am

Thanks for your reply, Antonio and anda_skoa.
and I found a problem that the animated GIFs are displayed a bit slow in KHTMLPart widget. any idea regarding this?

cheers.

This post has been edited 1 times, last edit by "yunfan" (Apr 1st 2005, 5:19am)


Posts: 15

Location: Padova, Italy

Occupation: Student

  • Send private message

5

Friday, April 1st 2005, 9:54am

On my system they are just OK. I've used KHTML part even on low spec machine, but still it is responsive.

What kde version are you using?
--
Antonio

6

Friday, April 1st 2005, 1:13pm

Hi antonio,

I am using KDE 3.3.2 with some patches. Probably it's not the khtmlpart problem. I've tried my code on another machine with gentoo system(kde 3.3.2), it works very well.

could you please help me for one more question? I've connect browserExtension's signal
openURLRequest, but it seems that it never grab the email addresses and I couldn't find a proper way to get those email addresses when user click on them. could you give some hints for this?

many thanks!

Posts: 15

Location: Padova, Italy

Occupation: Student

  • Send private message

7

Friday, April 1st 2005, 1:49pm

Sorry, but I haven't understood: do the signal get generated (when you click on a mai link) or does it not even get generated?
--
Antonio

8

Friday, April 1st 2005, 2:53pm

yes, the signal is generated.

what I have done is like following.
I subclass from KHTMLPart, in the constructor,

Source code

1
2
3
QObject::connect(browserExtension(), 
			SIGNAL(openURLRequest(const KURL &, const KParts::URLArgs &)), 
			SLOT(slotLinkClicked( const KURL &)));


then, in the slot slotLinkClicked

Source code

1
2
3
4
5
void EvaChatView::slotLinkClicked( const KURL & url)
{
	printf("KURL: %s\n", url.host().latin1());
       // do something
}


It turns out, when I wrote string
"<a href="http://www.qtforum.org">http://www.qtforum.org</a> "
into the class, and then clicked the url shown on the window, I got "KURL: www.qtforum.org" printed out. It just work fine.

But, whenever I wrote
"<a href="mailto:xxx@qtforum.org">xxx@qtforum.org</a>"
into my subclass of khtmlpart, I clicked on it, the console shows
"KURL: (null)"

Is there something wrong? I got stucked here for a couple of days, I thought to grab email address might need some other signal or method, that was why I said those words in the prevouis post. :(

sorry for my bad expression.

This post has been edited 1 times, last edit by "yunfan" (Apr 1st 2005, 2:58pm)


Posts: 15

Location: Padova, Italy

Occupation: Student

  • Send private message

9

Friday, April 1st 2005, 3:35pm

Well, try printing url.url(), this should print the unparsed string the KURL gets constructed with. It should be mailto:...

If I'm not mistaken url.host() works only with file: and http,ftp: URL types. To parse email addresses you should use url() and then extract the host manually.

I hope this has helped you
--
Antonio

10

Friday, April 1st 2005, 3:52pm

8o, ha, KURL...

I am very appriciated for your help. Thanks a lot!

anda_skoa

Professional

Posts: 1,273

Location: Graz, Austria

Occupation: Software Developer

  • Send private message

11

Friday, April 1st 2005, 4:03pm

The address part of the mailto URI could be the path, I think a host part would always be preceeded by //

Cheers,
_
Qt/KDE Developer
Debian User