<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>m2marcelo's Blog</title>
	<atom:link href="http://m2marcelo.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://m2marcelo.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Fri, 15 May 2009 20:24:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='m2marcelo.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>m2marcelo's Blog</title>
		<link>http://m2marcelo.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://m2marcelo.wordpress.com/osd.xml" title="m2marcelo&#039;s Blog" />
	<atom:link rel='hub' href='http://m2marcelo.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Updates in fancybrowser</title>
		<link>http://m2marcelo.wordpress.com/2009/04/30/fancybrowser/</link>
		<comments>http://m2marcelo.wordpress.com/2009/04/30/fancybrowser/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 18:14:16 +0000</pubDate>
		<dc:creator>Marcelo Morais</dc:creator>
				<category><![CDATA[Qt]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hi! Yes, this is first time blogging. Some colleagues at INdT and I had joined the WebKit Project, focusing mainly on the QtWebKit port. We started to work in their official backlog, the most important things right now are documentation, snippets and examples. I chose start with examples, because it&#8217;s a good way to get [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=m2marcelo.wordpress.com&amp;blog=7569002&amp;post=1&amp;subd=m2marcelo&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="text-align:justify;">Hi! Yes, this is first time blogging.</p>
<p style="text-align:justify;">Some colleagues at INdT and I had joined the WebKit Project, focusing mainly on the QtWebKit port. We started to work in their <a title="backlog" href="http://trac.webkit.org/wiki/QtWebKitTodo">official backlog</a>, the most important things right now are documentation, snippets and examples.</p>
<p style="text-align:justify;">I chose start with examples, because it&#8217;s a good way to get involved, I selected work with<a title="Qt DOM API" href="http://chaos.troll.no/~tavestbo/webkit/domapi/qwebelement.html"> Qt DOM API</a>, my friend <a href="http://tonikitoo.blogspot.com">tonikitoo</a> show me a post in <a href="http://labs.trolltech.com/blogs/2009/04/17/jquery-and-qwebelement/" target="_blank">Ariya&#8217;s blog</a> that shows this fancybrowser using QWebElement pretty well. The code is available in <a href="http://labs.trolltech.com/gitweb?p=GraphicsDojo">Graphics Dojo repository</a>, under the directory <tt>fancybrowser</tt>. Then I tried to do the exercise proposed by ariya and I implemented a new functionality to undo the highlighting of links and undo all the remove actions there, so the point is this task is change these functions to turn on/off all actions.</p>
<p style="text-align:justify;">The solution was pretty simple. First of all you need to inject a new style into the page loaded, like this:</p>
<p><!-- p, li { white-space: pre-wrap; } --></p>
<p style="text-indent:0;padding-left:30px;margin:0;"><!--StartFragment-->void addStyle() {</p>
<p style="text-indent:0;padding-left:60px;margin:0;">QString style = &#8220;&lt;style type=\&#8221;text/css\&#8221;&gt; .highlight{background-color:yellow} .hidden{display:none;} &lt;/style&gt;&#8221;;</p>
<p style="text-indent:0;padding-left:60px;margin:0;">QWebElement element = view-&gt;page()-&gt;mainFrame()-&gt;documentElement().findFirst(&#8220;body&#8221;);</p>
<p style="text-indent:0;padding-left:60px;margin:0;">element.appendInside(style);</p>
<p style="text-indent:0;padding-left:30px;margin:0;">}<!--EndFragment--></p>
<p><!-- p, li { white-space: pre-wrap; } --></p>
<p style="text-align:justify;">So now this style is inserted into body of the page and we can use it to turn on/off highlight and hide actions.</p>
<p style="text-align:justify;">We can do this as a toggle, check how we can do the highlight action:</p>
<p><!-- p, li { white-space: pre-wrap; } --></p>
<p style="text-indent:0;padding-left:30px;margin:0;"><!--StartFragment-->void highlightAllLinks(bool toggle) {</p>
<p style="text-indent:0;padding-left:60px;margin:0;">foreach (QWebElement element, view-&gt;page()-&gt;mainFrame()-&gt;findAllElements(&#8220;a&#8221;)) {</p>
<p style="text-indent:0;padding-left:90px;margin:0;">if (toggle) {</p>
<p style="text-indent:0;padding-left:120px;margin:0;">element.addClass(&#8220;highlight&#8221;);</p>
<p style="text-indent:0;padding-left:90px;margin:0;">} else {</p>
<p style="text-indent:0;padding-left:120px;margin:0;">element.removeClass(&#8220;highlight&#8221;);</p>
<p style="text-indent:0;padding-left:90px;margin:0;">}</p>
<p style="text-indent:0;padding-left:60px;margin:0;">}</p>
<p style="text-indent:0;padding-left:30px;margin:0;">}</p>
<p style="text-indent:0;padding-left:30px;margin:0;">
<p style="text-indent:0;margin:0;">The final result is this:</p>
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;"><img class="aligncenter size-full wp-image-11" title="webkit1" src="http://m2marcelo.files.wordpress.com/2009/04/webkit11.png?w=460&#038;h=357" alt="webkit1" width="460" height="357" /></p>
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;">After check the highlight action:</p>
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;"><img class="aligncenter size-full wp-image-12" title="webkit2" src="http://m2marcelo.files.wordpress.com/2009/04/webkit21.png?w=460&#038;h=357" alt="webkit2" width="460" height="357" /></p>
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;">The same solution could be used to other actions too.</p>
<p style="text-indent:0;margin:0;">
<p style="text-indent:0;margin:0;">Try it! =)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/m2marcelo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/m2marcelo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/m2marcelo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/m2marcelo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/m2marcelo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/m2marcelo.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/m2marcelo.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/m2marcelo.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=m2marcelo.wordpress.com&amp;blog=7569002&amp;post=1&amp;subd=m2marcelo&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://m2marcelo.wordpress.com/2009/04/30/fancybrowser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4b223122055168d048251b81304fd81c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">m2marcelo</media:title>
		</media:content>

		<media:content url="http://m2marcelo.files.wordpress.com/2009/04/webkit11.png" medium="image">
			<media:title type="html">webkit1</media:title>
		</media:content>

		<media:content url="http://m2marcelo.files.wordpress.com/2009/04/webkit21.png" medium="image">
			<media:title type="html">webkit2</media:title>
		</media:content>
	</item>
	</channel>
</rss>
