<?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>KTutorial project blog</title>
	<atom:link href="http://ktutorial.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://ktutorial.wordpress.com</link>
	<description>Blog (likely poorly updated :P ) about KTutorial project development</description>
	<lastBuildDate>Thu, 26 Nov 2009 01:26:45 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='ktutorial.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/e86c796c984c36646897d781f513a6e9?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>KTutorial project blog</title>
		<link>http://ktutorial.wordpress.com</link>
	</image>
			<item>
		<title>Some notes about Kross</title>
		<link>http://ktutorial.wordpress.com/2009/09/27/some-notes-about-kross/</link>
		<comments>http://ktutorial.wordpress.com/2009/09/27/some-notes-about-kross/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 01:09:20 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kross]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=45</guid>
		<description><![CDATA[While experimenting with Kross in order to implement scripted tutorials I collected a series of notes about what can and what can not be done with Kross. Although they are based on my own experiences (testing what happened if I changed things, reading Kross code and debugging it), I consider them to be pretty accurate [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=45&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>While experimenting with <a title="Kross scripting framework webpage" href="http://kross.dipe.org/">Kross</a> in order to implement scripted tutorials I collected a series of notes about what can and what can not be done with Kross. Although they are based on my own experiences (testing what happened if I changed things, reading Kross code and debugging it), I consider them to be pretty accurate (at the time of this writing, in the future it may change). But if you use this information for your own code and your computer explodes, don&#8217;t blame me <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Also take into account that I have tested this with Javascript and Python backends. I have no idea about how mature are other backends.</p>
<p>And now, let&#8217;s see those notes:</p>
<ul>
<li>Before Qt 4.5, only slots could be invoked from scripts. From Qt 4.5 and on, slots and methods marked with <a title="Q_INVOKABLE macro documentation" href="http://doc.trolltech.com/4.5/qobject.html#Q_INVOKABLE">Q_INVOKABLE</a> macro (which was introduced in Qt 4.5) can be invoked. Kross probably uses Qt Meta-Object System internally to make its magic.</li>
<li>Qt does not support Q_OBJECT classes that use templates. So, as you could expect, you can&#8217;t use templated classes or templated methods from scripts. Maybe playing with inheritance and method overriding it can be done&#8230; but I haven&#8217;t tested it.</li>
<li>It seems that in C++ classes you can&#8217;t have two slots (or invokable methods) with the same name and the same number of arguments (of different types). That is, it seems that Kross doesn&#8217;t call the appropriate slot based on the data types passed as arguments, but the first defined slot is always called. However, it only happens then the type of arguments is different, but their number is the same. If the name of the slots is the same but the number of arguments is different, Kross calls the slot with the matching number of arguments. So it supports a partial overloading of slots and invokable methods in C++ classes. Yes, even calling them from Python!</li>
<li>In Qt 4.5 the method <a title="QMetaObject::newInstance method documentation" href="http://doc.trolltech.com/4.5/qmetaobject.html#newInstance">newInstance</a> was added to QMetaObject, which as you can expect creates a new instance of the QObject subclass associated to the QMetaObject (if the constructor to use is marked as Q_INVOKABLE). However, Kross doesn&#8217;t seem to be able (at least yet) to create new objects using invokable constructors. Something similar can be got if, in the C++ code, a method is implemented that given the name of a class returns an object of it. For this, the class names have to be previously associated with their QMetaObject, as Qt doesn&#8217;t seem to have a way to get a QMetaObject for the given class name. However, like <a title="QMetaObject::invokeMethod method documentation" href="http://doc.trolltech.com/4.5/qmetaobject.html#invokeMethod">invokeMethod</a>, newInstance uses <a title="Q_ARG macro documentation" href="http://doc.trolltech.com/4.5/qmetaobject.html#Q_ARG">Q_ARG</a> for its arguments, and being a macro it receives its values hardcoded, so I don&#8217;t see a way to pass parameters from scripts. Nevertheless, a constructor without arguments can be made, finishing the proper object initialization using set methods, or an init method, or something like that. It is not the best solution, but it is good enough. An example of all this can be seen in <a title="KTutorial SVN Revision 50" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php?root=csl2-ktutorial&amp;rev=50&amp;view=rev">KTutorial commit #50</a>, where (among other things) creating WaitFors from scripts was added to ScriptModule.</li>
<li>Apart from simple types and objects from QObject and child classes there are other data types that can be used in scripts: those supported by QMetaType. These data types are normal classes, not inheriting from QObject. In fact, it seems that data types supported by QMetaType aren&#8217;t designed to be classes inheriting from QObject, as <a title="QObject documentation" href="http://doc.trolltech.com/4.5/qobject.html#no-copy-constructor-or-assignment-operator">classes inheriting from QObject can&#8217;t implement a copy constructor</a>, while <a title="qRegisterMetaType function documentation" href="http://doc.trolltech.com/4.5/qmetatype.html#qRegisterMetaType">QMetaTypes need a copy constructor to be registered using qRegisterMetaType</a>. Not being QObjects (thus lacking properties or slots), how they can be used from a script depends on the backend being used. For example, in Javascript backend &#8220;new QColor(255, 255, 255)&#8221; can be done, and also calling methods like red(), while in Python backend the QColor are just plain strings like &#8220;#ffffff&#8221;. A good example of what can be done and what can&#8217;t be done with each language can be seen looking in the <a title="Kross tests in KDE SVN" href="http://websvn.kde.org/trunk/KDE/kdelibs/kross/test/">unit tests of each Kross backend</a>.</li>
<li>When passing lists and dictionaries to C++ methods, the arguments have to be declared as QList and QMap (QHash doesn&#8217;t seem to be supported) storing QVariant (<a title="QVariantList typedef documentation" href="http://doc.trolltech.com/4.5/qvariant.html#QVariantList-typedef">QVariantList</a> and <a title="QVariantMap typedef documentation" href="http://doc.trolltech.com/4.5/qvariant.html#QVariantMap-typedef">QVariantMap</a>). If, for example, QMap&lt;QString, int&gt; is used, the method call is done successfully, and in the C++ method even the number of values stored in the map can be got. But when the values are tried to be got, it crashes, even if the type of the data matches those declared in the template. May it be a bug?</li>
<li>The pointer to simple types (like int*) fail when used as C++ method arguments. Instead of passing a pointer to the integer, the pointer itself contains the value of the integer. It seems that only pointers to QObject (and derived classes) are implemented.</li>
<li>Naturally, SIGNAL and SLOT macros don&#8217;t work in Kross scripts (as they are a C++ preprocessor matter). So Kross provides a special connect function (or method, depending on the backend) which just uses the names of the signals and slots, and it is not necessary to wrap them with the macros. However, what does it happen when you need to use the macros in other places that are not the typical connect (for example, because you do a connect internally in a method using the name of the signal or slot passed to it)? Looking through Qt code I saw that those macros just add &#8220;1&#8243; in the case of SLOT and &#8220;2&#8243; in the case of SIGNAL to the front of the string. So to solve this, just add internally in the method to which the names of signals or slots are passed the appropriate number at the front of the signature and you are done. Take a look to <a title="KTutorial SVN Revision 55" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php?root=csl2-ktutorial&amp;rev=55&amp;view=rev">KTutorial commit #55</a> as an example. Also take into account that if the name of the signal or slot to connect to is passed from the script to a C++ method, the method can&#8217;t be declared as receiving a const char* argument, but a QString.</li>
<li>Objects from classes created in scripts doesn&#8217;t seem to be compatible in any way with C++ code. I hoped that the interpreter made some kind of magic and &#8220;translated&#8221; them to QObject inherited classes, allowing them to be used in C++ methods receiving QObjects, but it&#8217;s not the case. As QObject class is neither available in scripts, classes can&#8217;t be made to inherit from it. However, this can be workarounded to some extent playing with signals. It can be done with a base class that emits signals with the object itself as argument in those methods that need to be overriden in child classes. The signals are connected to a function wrote in the script, and that function does the things that would have been done in the overriden method. See, for example, the test method stepWithCustomSetup in <a title="ScriptingTest in KTutorial SVN Revision 58" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php/trunk/ktutorial/test/scripting/ScriptingTest.cpp?view=markup&amp;root=csl2-ktutorial&amp;pathrev=58">ScriptingTest</a> and the <a title="src/scripting directory in KTutorial SVN Revision 57" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php/trunk/ktutorial/src/scripting/?root=csl2-ktutorial&amp;pathrev=57">ScriptedTutorial</a> class.</li>
<li>Both <a title="Module plugins in Kross introduction tutorial" href="http://techbase.kde.org/Development/Tutorials/Kross/Introduction#The_Module_plugins">modules</a> and <a title="Kross::Action::addQObject documentation" href="http://api.kde.org/4.x-api/kdelibs-apidocs/kross/html/classKross_1_1Action.html#a609ee84f907acb454b839389f6e0c197">QObjects added to Kross actions</a> (using Kross::Manager::self().addObject() the objects can be added to all the Kross actions) can be used to feed the scripts with C++ objects. In the scripts, modules will be loaded using Kross.module(&#8220;moduleName&#8221;), whereas QObjects can be used directly with the name they were gave (in the examples of the <a title="Kross tutorials in KDE TechBase" href="http://techbase.kde.org/Development/Languages/Kross">tutorials</a> the objects are imported when Python is used, but at least based on the tests I made it isn&#8217;t necessary).Â  Personally, I find adding the QObjects to use way easier than using modules (at least, with KTutorial current design).</li>
<li>In the case of Python, the methods added by Kross (and which naturally can be called) can be seen in <a title="PythonExtension.cpp in latest KDE SVN" href="http://websvn.kde.org/trunk/KDE/kdebindings/python/krosspython/pythonextension.cpp?view=markup">kdebindings/python/krosspython/pythonextension.cpp</a>, in PythonExtension constructor. Those methods are, among others, className() or slotNames().</li>
<li>Kross provides a translation module that makes possible internationalize scripts and localize them using .po files like the rest of KDE. The module is <a title="Kross:TranslationModule documentation" href="http://http://api.kde.org/4.x-api/kdelibs-apidocs/kross/html/classKross_1_1TranslationModule.html">Kross::TranslationModule</a> and offers the typical functions i18n, i18nc, etcetera. However, I still have to check how string extraction works in this case, and how to localize a script added a posteriori, for example, downloaded via <a title="GHNS project homepage" href="http://ghns.freedesktop.org/">&#8220;Get Hot New Stuff!&#8221;</a>. All this suggests that this matter will be worth its own post.</li>
<li>In the classes of the C++ objects used in scripts, the arguments of the signals and the return values of the slots that are not declared as pure QObject* but as QObject subclasses don&#8217;t work. On the other hand, the arguments of the slots can be QObject subclasses without any problem.</li>
<li><a title="WrapperInterface class documentation" href="http://api.kde.org/4.x-api/kdelibs-apidocs/kross/html/classKross_1_1WrapperInterface.html">WrapperInterface</a> class makes possible to use in scripts objects of classes that aren&#8217;t QObject*, nor QWidget*, nor any of the data types supported by QVariant. Unfortunately, although WrapperInterface is something at a generic level in Kross, it isn&#8217;t assured that it will work, as it depends on the backend (and thus, the language) used. The Javascript backend doesn&#8217;t seem to support this system, although the Python one does.</li>
<li>If we know that the scripts will only be written in languages which backend support WrapperInterface, it can be done the arguments of the signals and the return value of the slots of the C++ classes not to need to be declared as QObject*, but being able to be declared as the concrete subclass they belong to. For this, a handler for each class should be added, as shown below:<br />
<code>QVariant SomeQObjectSubclassHandler(void* ptr) {<br />
QVariant r;<br />
r.setValue( static_cast(ptr) );<br />
return r;<br />
}<br />
void Scripting::initialization() {<br />
...<br />
Kross::Manager::self().registerMetaTypeHandler("SomeQObjectSubclass*", SomeQObjectSubclassHandler);<br />
...<br />
}</code></li>
<li>At first, I happily believed that the functions defined in scripts would be magically translated to slots of some object and that in C++ code a signal could be connected to a function in the script using that object. That, unfortunately, doesn&#8217;t happen (take into account that signals can be connected to functions, but in the script, not in C++ code as I needed). However, as script functions can be called from C++ code, it can be workarounded to some extent calling the corresponding function when a signal is emitted. An example can be seen in <a title="KTutorial SVN Revision 53" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php?root=csl2-ktutorial&amp;rev=53&amp;view=rev">KTutorial commit #53</a> (although what I needed was under a pretty controlled situation, where signals included the emitter as their only argument).</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/45/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/45/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/45/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=45&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2009/09/27/some-notes-about-kross/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>Qt Meta-Object System and namespaces</title>
		<link>http://ktutorial.wordpress.com/2009/04/26/qt-meta-object-system-and-namespaces/</link>
		<comments>http://ktutorial.wordpress.com/2009/04/26/qt-meta-object-system-and-namespaces/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 22:56:43 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[namespace]]></category>
		<category><![CDATA[qt]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=41</guid>
		<description><![CDATA[In my recent work in KTutorial (implementing scripted tutorials using Kross) I stumbled upon some problems with Qt Meta-Object system and namespaces that I think are worth mentioning.
Note that these comments apply to Qt 4.5.1. In newer versions the described behaviour may be different (and, in the case of the bug, hopefully it will be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=41&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In my recent work in KTutorial (implementing scripted tutorials using Kross) I stumbled upon some problems with <a title="Meta-Object System in Qt 4.5 Documentation" href="http://doc.trolltech.com/4.5/metaobjects.html">Qt Meta-Object system</a> and namespaces that I think are worth mentioning.</p>
<p>Note that these comments apply to Qt 4.5.1. In newer versions the described behaviour may be different (and, in the case of the bug, <span style="text-decoration:line-through;">hopefully it will be already fixed</span> it is fixed in Qt 4.5.3.).</p>
<p>The first is more something to take into account than a problem. When a signal or slot is connected (using <em>QObject::connect</em> directly, or indirectly, for example, through <em>QSignalSpy</em>) the types of the arguments should be qualified using the same namespace used in the signal or slot declaration. You may declare it with the class name alone, without namespace, but only if you always use connect with the class name alone. That is, you always use the namespace, or you never use the namespace, but you can&#8217;t mix it.</p>
<p>The second, a strange behaviour if you don&#8217;t know what&#8217;s going on, involves namespaces in signal signatures, QSignalSpy and QVariant. A perfect mix. <a title="QSignalSpy in Qt 4.5 Documentation" href="http://doc.trolltech.com/4.5/qsignalspy.html">QSignalSpy</a> is a useful class from QtTest module that can be used to record the emissions for a signal of an object. The arguments are stored as <a title="QVariant inQt 4.5 Documentation" href="http://doc.trolltech.com/4.5/qvariant.html">QVariant</a> objects, that act as general containers for data types.</p>
<p>By default, QVariant supports most of Qt data types, but it can also store other types once they are registered. After using <a title="Q_DECLARE_METATYPE in Qt 4.5 Documentation" href="http://doc.trolltech.com/4.5/qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE </a>macro, a type can be stored in a QVariant (provided it has a public default constructor, public copy constructor and public destructor, which holds true for pointers to any type). Without it, the code won&#8217;t even compile.</p>
<p>However, when the type is used in the argument of a signal spied by a QSignalSpy, the type must be also registered using <a title="qRegisterMetaType in Qt 4.5 Documentation" href="http://doc.trolltech.com/4.5/qmetatype.html#qRegisterMetaType">qRegisterMetaType</a>. If not done, it complaints in debug output at runtime with &#8220;Don&#8217;t know how to handle &#8217;scripting::ScriptedTutorial*&#8217;, use qRegisterMetaType to register it.&#8221;.</p>
<p>The strange behaviour comes into play when namespaces are added to the party. If a signal has an argument that is a type (or a pointer to a type) in a namespace, as said above you can declare the argument with the class name alone. If the type is registered with Q_DECLARE_METATYPE and qRegisterMetaType (with the class name alone, without namespace), QSignalSpy will record the emitted signals, and when the QVariant that stored the argument is queried for the userType(), it will even return the same id as qRegisterMetaType returned when the argument type was registered. Apparently, it works.</p>
<p>However, there is no way to get the value of the argument. When a <a title="qvariant_cast in Qt 4.5 Documentation" href="http://doc.trolltech.com/4.5/qvariant.html#qvariant_cast">qvariant_cast</a> is used on the QVariant that stores the argument, a default constructed value is returned.  That doesn&#8217;t mean that the argument can&#8217;t be sent in a signal. If it was connected to a slot, it would have received the true argument value. But qvariant_cast doesn&#8217;t know how to manage the argument type.</p>
<p>Why? Because, for qvariant_cast, the class name, and the class name qualified with the namespace are different types. When the type is declared using Q_DECLARE_METATYPE, internally the full qualified name is used. If the name registered in qRegisterMetaType doesn&#8217;t includes the namespace, it won&#8217;t be recognized by qvariant_cast. So the full qualified name must be used in qRegisterMetaType. And if this is done, the full qualified name must be used also in QSignalSpy, and therefore in the declaration of the signal. So, to sum up: use the full qualified name of classes in signals and slots, you&#8217;ll live longer and happier <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>See testSetup() method for an example of all this in <a title="ScriptedTutorial.cpp in KTutorial SVN revision 48" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php/trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp?root=csl2-ktutorial&amp;rev=48&amp;view=markup">KTutorial commit #48</a>.</p>
<p>The last is a true problem, as it is an already reported bug (<a title="Qt Task Tracker, entry 246221" href="http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&amp;id=246221">246221 &#8211; QMetaObject::newInstance() returns 0 for class in namespace</a> (as it is an old bug, <a title="I cannot find a bug which has been reported before in the Qt Bug Tracker, why has it not been transferred? " href="http://qt.nokia.com/developer/faqs/i-cannot-find-a-bug-which-has-been-reported-before-in-the-qt-bug-tracker-why-has-it-not-been-transferred">it seems to be no longer online</a>)). The <a title="QMetaObject::newInstance in Qt 4.5 Documentation" href="http://doc.trolltech.com/4.5/qmetaobject.html#newInstance">QMetaObject::newInstance</a> method, introduced in Qt 4.5, doesn&#8217;t work when the class is in a namespace. The problem seems to be that when the constructor signature is prepared in newInstance code it includes the namespace. However, indexOfConstructor method doesn&#8217;t use the namespace, so when the constructor is looked for it isn&#8217;t found and no new instance is created. The bug is fixed in Qt 4.5.3.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=41&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2009/04/26/qt-meta-object-system-and-namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>Note to myself</title>
		<link>http://ktutorial.wordpress.com/2009/03/31/note-to-myself/</link>
		<comments>http://ktutorial.wordpress.com/2009/03/31/note-to-myself/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 17:27:12 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=37</guid>
		<description><![CDATA[RPATH is great. But remember, when the library is installed in a path included in LD_LIBRARY_PATH, the installed library takes priority over the one pointed by RPATH.
Next time that QTest executables run directly or through Valgrind don&#8217;t change their behavior after modifying the library code, but when executed through shell files they do, that&#8217;s what [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=37&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>RPATH is great. But remember, when the library is installed in a path included in LD_LIBRARY_PATH, the installed library takes priority over the one pointed by RPATH.</p>
<p>Next time that QTest executables run directly or through Valgrind don&#8217;t change their behavior after modifying the library code, but when executed through shell files they do, that&#8217;s what is going on.</p>
<p>Yes, pretty obvious. But I&#8217;m sure that it is not the first time that you get stuck for an hour in something like that <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  (and that then, after realizing what&#8217;s happening, you feel like a moron <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ).</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=37&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2009/03/31/note-to-myself/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>Unit testing a KDE 4 library</title>
		<link>http://ktutorial.wordpress.com/2009/03/18/unit-testing-a-kde-4-library/</link>
		<comments>http://ktutorial.wordpress.com/2009/03/18/unit-testing-a-kde-4-library/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 15:59:38 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ctest]]></category>
		<category><![CDATA[rpath]]></category>
		<category><![CDATA[unittest]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=14</guid>
		<description><![CDATA[Here it is, my first English post!
I have still some things to finish (unrelated to KTutorial) before I can get a steady development pace, but until I finish them I&#8217;m going to make some sporadic work, mostly fixing problems (not  necessarily bugs) to have a better base. For example, improving the unit tests.
I&#8217;m an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=14&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Here it is, my first English post!</p>
<p>I have still some things to finish (unrelated to KTutorial) before I can get a steady development pace, but until I finish them I&#8217;m going to make some sporadic work, mostly fixing problems (not  necessarily bugs) to have a better base. For example, improving the unit tests.</p>
<p>I&#8217;m an advocate of testing before coding, but I can&#8217;t understand how or why in this project I had only 1 class and 4 methods tested. That had to change! So I entered in a test frenzy state and covered most of the code (KDevelop4 coverage plugin reports a healthy 91% coverage) with tests, which also helped to unveil some lurking bugs.</p>
<p>However, I&#8217;m not going to talk about the tests themselves, but about the infrastructure for them.</p>
<p><strong>Executing tests without installing the library</strong></p>
<p>When checking the first and (then) only test case I found that it passed when run using the shell wrapper, but not when run calling the executable directly.</p>
<p>Shell wrapper? What are you taking about? Ok, ok, let me explain. When you develop a library, you&#8217;re likely developing a <a title="Library (computing) article in Wikipedia" href="http://en.wikipedia.org/wiki/Dynamic_library">dynamic library</a>. That is, the applications using it will link to it when executed, not when compiled, and the library will remain as a separate file in the system.</p>
<p>In GNU/Linux the linker usually looks for the libraries in system directories. So if your test executable is linked against your dynamic library, the linker won&#8217;t find it until you install it. Apart from using system wide configuration, you can tell the linker other paths to look for the libraries with LD_LIBRARY_PATH environment variable.</p>
<p>And here is where the shell wrapper appears. The <a title="KDE4Macros.cmake in KDE SVN" href="http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/KDE4Macros.cmake">KDE 4 macros for CMake</a> add, for each executable, a script which sets the needed paths in LD_LIBRARY_PATH for the executable to run and then calls it. This way, you can run your executable linked with dynamic libraries that are in the build directory but not installed yet.</p>
<p>But I needed the test executable to work even without the shell wrapper so I can run all the tests through CTest (more on this later). Unlike dynamic libraries, static libraries are linked at compiling time and added to the executable, so they aren&#8217;t needed separately.</p>
<p>So I thought &#8220;well, let&#8217;s create a ktutorial-static library to be used only by test executables and not even to be installed&#8221;. However, I wasn&#8217;t satisfied with that because the size of each test executable is much larger, specially in full debug mode, as each of them now contain the library. And I also felt that it was just a dirty workaround and there had to be a better solution.</p>
<p>And yes, there was. Reading the KDE 4 Macros documentation I found that KDE4_ADD_UNIT_TEST &#8220;adds a unit test [...] (that) will be built with RPATH pointing to the build dir&#8221;. Mmm, what was that RPATH thing? CMake wiki gave me the <a title="CMake RPATH handling" href="http://www.cmake.org/Wiki/CMake_RPATH_handling">answer</a>: it was just what I was looking for. It&#8217;s like hardcoding LD_LIBRARY_PATH in the executable.</p>
<p>But, if the macro sets it, why didn&#8217;t it work? After some diving in KDE 4 Macros I concluded that it was a bug and opened <a title="Bug 176468" href="http://bugs.kde.org/show_bug.cgi?id=176468">RPATH isn&#8217;t set for tests added with KDE4_ADD_UNIT_TEST</a> report. The bug is now fixed, so all the things explained here are superfluous, as now KDE4_ADD_UNIT_TEST works out of the box with dynamic libraries. Yes, you have wasted your time reading all this, sorry <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><strong>Running the tests</strong></p>
<p>But, why do I need to execute the tests not using the shell wrapper? In KDE 4, the preferred unit testing library is <a title="Qt Unit Test Library" href="http://doc.trolltech.com/solutions/4/qttestlib/">QtTestLib</a>. In QtTestLib each test case is an executable on its own, unlike other libraries where you can execute a test suite that groups several test cases. So you need a way to run all the tests without needing to run each test executable alone.</p>
<p>CMake provides its own test system, <a title="CTest FAQ" href="http://www.vtk.org/Wiki/CTest:FAQ">CTest</a>. It has several fancy features, like sending the results of the tests to <a title="How to use CTest with dashboards" href="http://www.paraview.org/Wiki/CMake_Testing_With_CTest#Dashboards">testing dashboards</a>. But right now I just want to execute all the tests and see whether they pass or not. Fortunately, with CMake and CTest that&#8217;s a piece of cake.</p>
<p>CTest uses a <a title="Describing tests for CTest" href="http://www.vtk.org/Wiki/CMake_Generating_Testing_Files#Description_of_Tests">CTestTestfile.cmake</a> (or DartTestfile.txt, for legacy purposes) where it is specified the tests for its directory and subdirectories to look for other CTestTestfile.cmake. A CTestTestfile.cmake is created and filled by CMake in each build directory if ENABLE_TESTING command was run, which it is when including <a title="KDE4Defaults.cmake in KDE SVN" href="http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/KDE4Defaults.cmake?view=markup">KDE4Defaults</a>. CMake macro <a title="add_test" href="http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_test">ADD_TEST</a> adds a new test in the CTestTestfile.cmake of its directory. This macro is called from KDE4_ADD_UNIT_TEST, so using it effectively prepares CTest to run all the tests, even those in subdirectories of the base test directory. However, the tests are executed directly, not through their shell wrapper.</p>
<p>Well, I thought that. But&#8230; in fact, the generated CTestTestfile.cmake do use the shell wrapper. Since <a title="Commit 764809 in KDE SVN" href="http://websvn.kde.org/?view=rev&amp;revision=764809">January 2008</a>&#8230; But I was sooo smart to forget to update my KDE environment since then. Don&#8217;t ask&#8230; (Note, however, that this was written some months ago, although I didn&#8217;t publish it until now <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  )</p>
<p>So now CTest works out of the box with KDE 4 Macros. We only have to build the tests (calling CMake with <a title="CMake tutorial for KDE 4" href="http://techbase.kde.org/Development/Tutorials/CMake#Command_Line_Variables">KDE4_BUILD_TESTS=ON variable</a> they will be built with the rest of the project) and run CTest in our <em>build/test</em> directory. It will execute all the tests in that directory and, recursively, in all the needed subdirectories. If we need a more detailed output than the default summary, run ctest with -V or even -VV parameters to see the full test output.</p>
<p><strong>Running QTest test from KDevelop4</strong></p>
<p>A very interesting new feature of <a title="KDevelop homepage" href="http://www.kdevelop.org">KDevelop4</a> is the support for unit test frameworks (although, as far as I know, only QTest works at this moment). With QTest plugin, you can enable and disable QTest tests to execute and see their results.</p>
<p>With some build systems, you must configure the plugin specifying the executables to be taken into account. However, if your project uses CMake, they are automatically discovered using CTestTestfile.cmake files (there is no problem even if they specify non-QTest tests, as these would be ignored).</p>
<p>There is only a little requeriment: there must be a CTestTestfile.cmake file in the root build directory. So just by using ENABLE_TESTING command in the root CMakeLists.txt file the CTestTestfile.cmake file is created and filled to recursively search in its subdirectories.</p>
<p>The only drawback with this approach is that CTestTestfile.cmake files will be created even in build directories where they aren&#8217;t needed (for example, src). However, although it is not the best solution, it is good enough <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>Macro for adding several tests at once in CMakeLists.txt</strong></p>
<p>In order to add a test, you need two or three CMake macros: KDE4_ADD_UNIT_TEST, TARGET_LINK_LIBRARIES and, optionally, SET (to set a variable with the list of files of the tests). As unit tests usually need just one file, you can avoid creating a variable and set the file in the KDE4_ADD_UNIT_TEST macro without losing legibility.</p>
<p>Anyway, the two calls are almost identical for every test, just changing the name of the test. It will be better to tell CMake just the name of the tests, instead of copy-pasting the calls for each test.</p>
<p>Of course, this can be easily done. As I have no idea about CMake programming, I took a look at <a title="CMakeLists.txt for kdecore in KDE SVN" href="http://websvn.kde.org/trunk/KDE/kdelibs/kdecore/tests/CMakeLists.txt?view=markup">KDECORE_UNIT_TESTS</a> macro in CMakeLists.txt for kdecore and tweaked it for my own needs, as seen in <a title="KTutorial SVN revision 24" href="https://forja.rediris.es/plugins/scmsvn/viewcvs.php?root=csl2-ktutorial&amp;rev=24&amp;view=rev">KTutorial commit #24</a>.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=14&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2009/03/18/unit-testing-a-kde-4-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>Preparando la vuelta al trabajo</title>
		<link>http://ktutorial.wordpress.com/2008/10/16/preparando-la-vuelta-al-trabajo/</link>
		<comments>http://ktutorial.wordpress.com/2008/10/16/preparando-la-vuelta-al-trabajo/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 17:05:09 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=10</guid>
		<description><![CDATA[Al trabajo en KTutorial, me refiero  
Desgraciadamente estos meses desde mi Ãºltimo mensaje no tuve apenas tiempo libre y no pude continuar con el desarrollo de KTutorial desde entonces. Pero afortunadamente eso cambiarÃ¡ pronto.
Mi intenciÃ³n es continuar el desarrollo de KTutorial como mi proyecto de fin de carrera, por lo que, a no ser [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=10&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Al trabajo en KTutorial, me refiero <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Desgraciadamente estos meses desde mi Ãºltimo mensaje no tuve apenas tiempo libre y no pude continuar con el desarrollo de KTutorial desde entonces. Pero afortunadamente eso cambiarÃ¡ pronto.</p>
<p>Mi intenciÃ³n es continuar el desarrollo de KTutorial como mi proyecto de fin de carrera, por lo que, a no ser que las cosas se tuerzan mucho, para junio confÃ­o en haber implementado una serie de nuevas caracterÃ­sticas, acompaÃ±adas cÃ³mo no de una buena documentaciÃ³n para desarrolladores y usuarios.</p>
<p>Dichas caracterÃ­sticas son, principalmente, las ya mencionadas en su dÃ­a de tutoriales interpretados e integraciÃ³n con GHNS, junto a una notable simplificaciÃ³n de la ediciÃ³n de tutoriales, puede que mediante un editor grÃ¡fico. ConfÃ­o en conseguir un nivel de desarrollo suficiente como para que pueda interesar a los desarrolladores de KDE y, quiÃ©n sabe, quizÃ¡s poder verlo en KDE 4.3 Ã³ 4.4&#8230; aunque eso sÃ³lo el tiempo lo dirÃ¡ <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>AÃºn no me pondrÃ© con ello, no obstante, ya que antes necesito terminar algunas tareas que tengo pendientes. ConfÃ­o en haberlas despachado en unas semanas.</p>
<p>Respecto al <a title="PÃ¡gina web del Concurso Universitario de Software Libre" href="http://www.concursosoftwarelibre.org">Concurso Universitario de Software Libre</a>, este aÃ±o volverÃ© a presentarme, pero no con KTutorial. Supongo que, dado que voy a implementar nuevas caracterÃ­sticas, podrÃ­a hacerlo, pero prefiero presentar algo nuevo. No sÃ©, manÃ­as mÃ­as. Ya veremos quÃ© tal sale, aunque mi intuiciÃ³n me dice que voy a estar muy enredado con KTutorial y apenas voy a poder dedicarle tiempo al otro proyecto. Pero bueno, lo importante es participar <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Y para acabar, de ahora en adelante seguramente escribirÃ© las entradas en inglÃ©s (bueno, &#8220;inglÃ©s&#8221; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ), ya que considero que es mÃ¡s apropiado dada la naturaleza del blog. Supongo que no era necesario indicarlo y que quien leyese las prÃ³ximas entradas serÃ­a capaz de deducirlo sin ayuda&#8230; pero nunca se sabe&#8230; <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Â¡Hasta dentro de unas semanas!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/10/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/10/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/10/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=10&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2008/10/16/preparando-la-vuelta-al-trabajo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>VersiÃ³n 0.1 disponible</title>
		<link>http://ktutorial.wordpress.com/2008/04/04/version-01-disponible/</link>
		<comments>http://ktutorial.wordpress.com/2008/04/04/version-01-disponible/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 19:05:51 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=9</guid>
		<description><![CDATA[Realmente, ya hace una semana que la publiquÃ©. Pero fue una semana de locura con cosas de clase y no encontrÃ© un triste momento para escribirlo aquÃ­ en el blog  Â Pero bueno, menos lamentar y mÃ¡s informar  
La versiÃ³n 0.1, asÃ­ como las instrucciones de compilaciÃ³n e instalaciÃ³n, puede encontrarse en la secciÃ³n [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=9&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Realmente, ya hace una semana que la publiquÃ©. Pero fue una semana de locura con cosas de clase y no encontrÃ© un triste momento para escribirlo aquÃ­ en el blog <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> Â Pero bueno, menos lamentar y mÃ¡s informar <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>La versiÃ³n 0.1, asÃ­ como las instrucciones de compilaciÃ³n e instalaciÃ³n, puede encontrarse en la <a href="http://csl2-ktutorial.forja.rediris.es/download.html" title="SecciÃ³n de descargas en la web de KTutorial">secciÃ³n de descargas</a> de la <a href="http://csl2-ktutorial.forja.rediris.es" title="Web del proyecto KTutorial">web del proyecto</a>.</p>
<p>AprovechÃ© tambiÃ©n para incluir la <a href="http://csl2-ktutorial.forja.rediris.es/apidocs/index.html" title="DocumentaciÃ³n de la API generada por Doxygen">documentaciÃ³n de la API</a>, un <a href="http://csl2-ktutorial.forja.rediris.es/doc/using.html" title="Tutorial de uso de KTutorial en una aplicaciÃ³n">tutorial de uso de la biblioteca</a> (para desarrolladores de aplicaciones, no para usuarios finales) y un <a href="http://csl2-ktutorial.forja.rediris.es/doc/design.html" title="DocumentaciÃ³n del diseÃ±o de KTutorial">documento de diseÃ±o</a>. El documento de diseÃ±o, no obstante, aÃºn es mÃ¡s un simple borrador que un documento serio.</p>
<p>Â¿Y ahora? Ahora, lÃ³gicamente, a por la versiÃ³n 0.2. Inicialmente era donde me proponÃ­a llegar antes de terminar el concurso,Â  con algo de tiempo para empezar a revelar la existencia del proyecto a los desarrolladores de KDE y con suerte recibir algo de feedback (la versiÃ³n espaÃ±ola de la palabra no acaba de gustarme <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ). Pero con todo el lÃ­o que tuve estas Ãºltimas semanas con cosas de la universidad, eso no va a ser posible. Â¡Una pena!</p>
<p>La idea para esta versiÃ³n 0.2 es poder crear tutoriales interpretados mediante scripts (gracias a <a href="http://kross.dipe.org/" title="PÃ¡gina del proyecto Kross">Kross</a>), en lugar de compilados en C++, y utilizar <a href="http://ghns.freedesktop.org/" title="PÃ¡gina del proyecto Get Hot New Stuff">Get Hot New Stuff</a> para poder descargar nuevos tutoriales con facilidad.</p>
<p>AsÃ­ que nada, ahora, a intentar integrar Kross y GHNS en la medida de lo posible con el tiempo del que dispongo. AÃºn no investiguÃ© GHNS, pero Kross parece que no va a ser tan sencillo como pensaba. Mejor dicho, la integraciÃ³n en sÃ­ sÃ­ es sencilla. Conseguir lo que creÃ­a que podrÃ­a conseguir directamente con ella, no <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Pero eso es otra historia, y como tal ya habrÃ¡ tiempo de contarla.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ktutorial.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ktutorial.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=9&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2008/04/04/version-01-disponible/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>Â¡EstÃ¡ vivo! Â¡Viiivooo!</title>
		<link>http://ktutorial.wordpress.com/2008/02/07/%c2%a1esta-vivo-%c2%a1viiivooo/</link>
		<comments>http://ktutorial.wordpress.com/2008/02/07/%c2%a1esta-vivo-%c2%a1viiivooo/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 22:21:09 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kde]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=8</guid>
		<description><![CDATA[Y por fin llegÃ³ el dÃ­a de mostrar a la bestiecilla. Lo cierto es que me gustarÃ­a explayarme mÃ¡s, pero tengo examen maÃ±ana y no me sobra el tiempo, asÃ­ que serÃ© breve  
Enlazo tres vÃ­deos de KTutorial en funcionamiento a travÃ©s de una aplicaciÃ³n de prueba:

ktutorial-limpiar.ogg: muestra un tutorial muy sencillo y cÃ³mo [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=8&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Y por fin llegÃ³ el dÃ­a de mostrar a la bestiecilla. Lo cierto es que me gustarÃ­a explayarme mÃ¡s, pero tengo examen maÃ±ana y no me sobra el tiempo, asÃ­ que serÃ© breve <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Enlazo tres vÃ­deos de KTutorial en funcionamiento a travÃ©s de una aplicaciÃ³n de prueba:</p>
<ul>
<li><a href="http://csl2-ktutorial.forja.rediris.es/files/ktutorial-limpiar.ogg" title="VÃdeo de ejemplo de tutorial sencillo en KTutorial">ktutorial-limpiar.ogg</a>: muestra un tutorial muy sencillo y cÃ³mo puede moverse el Widget de los tutoriales por la pantalla.</li>
<li><a href="http://csl2-ktutorial.forja.rediris.es/files/ktutorial-mover.ogg" title="VÃdeo de ejemplo de tutorial con opciones en KTutorial">ktutorial-mover.ogg</a>: un tutorial ya mÃ¡s complejo (el cÃ³digo presenta filtrado de eventos para poder interceptar pulsaciones del ratÃ³n, por ejemplo) que muestra el uso de opciones en los pasos.</li>
<li><a href="http://csl2-ktutorial.forja.rediris.es/files/ktutorial-l10n.ogg" title="VÃdeo de ejemplo de localizaciÃ³n en KTutorial">ktutorial-l10n.ogg</a>: simplemente muestra cÃ³mo KTutorial estÃ¡ internacionalizado y puede localizarse como cualquier otra aplicaciÃ³n de KDE (en el vÃ­deo se muestra la localizaciÃ³n al espaÃ±ol).</li>
</ul>
<p>Los vÃ­deos fueron realizados utilizando <a href="http://recordmydesktop.iovar.org" title="PÃ¡gina del proyecto recordMyDesktop">recordMyDesktop</a>, por tanto utiliza sÃ³lo formatos libres. En concreto, el <a href="http://xiph.org/ogg/" title="PÃ¡gina del formato contenedor Ogg">contenedor ogg</a> y el formato de <a href="http://theora.org/" title="PÃ¡gina del formato de vï¿½deo Theora">vÃ­deo Theora</a>. No hay audio en estos tres vÃ­deos.</p>
<p>Los vÃ­deos deberÃ­an estar alojados en la <a href="http://csl2-ktutorial.forja.rediris.es/" title="PÃ¡gina del proyecto KTutorial">web del proyecto</a>&#8230; pero hoy no soy capaz de conectarme mediante SCP a la <a href="http://forja.rediris.es/" title="Forja de RedIRIS">forja de RedIRIS</a> (me devuelve un hermoso &#8220;Lost connection&#8221;), asÃ­ que temporalmente estÃ¡n alojados en otro servidor. Â¡Gracias Luis!</p>
<p><b>ActualizaciÃ³n:Â  </b>los vÃ­deos ya estÃ¡n alojados en la web del proyecto, pues se resolviÃ³ el problema de SCP (algo debÃ­a haber en el lado del servidor, ya que yo no hice nada mÃ¡s que probar lo mismo dÃ­as mÃ¡s tarde).</p>
<p>En los prÃ³ximos dÃ­as intentarÃ© subir el cÃ³digo fuente del framework y la aplicaciÃ³n de prueba a la forja, asÃ­ como la documentaciÃ³n de la API en la pÃ¡gina web (cuando consiga transferir ficheros a ella, claro).</p>
<p>Oh, huelga decir que los vÃ­deos estÃ¡n bajo licencia <a href="http://creativecommons.org/licenses/by-sa/2.5/es/" title="Licencia CC by-sa">Creative Commons Attribution-Share Alike</a> <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ktutorial.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ktutorial.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=8&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2008/02/07/%c2%a1esta-vivo-%c2%a1viiivooo/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>Bibliotecas dinÃ¡micas en KDE 4</title>
		<link>http://ktutorial.wordpress.com/2008/02/06/bibliotecas-dinamicas-en-kde-4/</link>
		<comments>http://ktutorial.wordpress.com/2008/02/06/bibliotecas-dinamicas-en-kde-4/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 19:34:22 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[biblioteca dinÃ¡mica]]></category>
		<category><![CDATA[kde]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=7</guid>
		<description><![CDATA[VersiÃ³n corta: si desarrollas una biblioteca dinÃ¡mica para KDE, debes marcar tus clases con la macro KNOMBREBIBLIOTECA_EXPORT (de forma que su definiciÃ³n quede como &#8220;class KNOMBREBIBLIOTECA_EXPORT nombreClase: public claseBase {&#8230;&#8220;), y definir esa macro en un archivo de cabecera knombrebiblioteca_export.h (los nombres no tienen por quÃ© ser necesariamente asÃ­, pero por seguir la prÃ¡ctica comÃºn) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=7&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>VersiÃ³n corta: si desarrollas una biblioteca dinÃ¡mica para KDE, debes marcar tus clases con la macro <i>KNOMBREBIBLIOTECA_EXPORT</i> (de forma que su definiciÃ³n quede como &#8220;<i>class KNOMBREBIBLIOTECA_EXPORT nombreClase: public claseBase {&#8230;</i>&#8220;), y definir esa macro en un archivo de cabecera <i>knombrebiblioteca_export.h</i> (los nombres no tienen por quÃ© ser necesariamente asÃ­, pero por seguir la prÃ¡ctica comÃºn) con un contenido adaptado a la biblioteca en cuestiÃ³n. VÃ©ase como ejemplo cualquiera de los archivos <i>include/kloquesea_export.h</i> de KDE 4, asÃ­ como los archivos de cabecera de las clases que los usan.</p>
<p>Para quien quiera aburrirse con la versiÃ³n larga y detallada de mis aventuras y desventuras hasta llegar a tan sencilla conclusiÃ³n, a continuaciÃ³n viene la versiÃ³n larga.</p>
<p>&#8220;El miedo es el camino hacia el Lado Oscuro. El miedo lleva a la ira, la ira lleva al odio, el odio lleva al sufrimiento. Veo mucho miedo en ti.&#8221; Con estas palabras el maestro Yoda expresaba su preocupaciÃ³n ante el entrenamiento en los caminos de la Fuerza del joven Anakin Skywalker. Pues bien, si hoy el maestro Yoda me hubiese examinado a mÃ­, miedo no habrÃ­a encontrado. Ahora que de ira, odio y sufrimiento iba servido.</p>
<p>Este cÃºmulo de sensaciones tan poco agradables eran debidas al cansancio y desesperaciÃ³n acumuladas durante las Â¿5? horas que habÃ­a pasado intentando averiguar por quÃ© cuando convertÃ­ la biblioteca KTutorial de estÃ¡tica a dinÃ¡mica el enlazado desde una aplicaciÃ³n de prueba fallaba (una larga retahÃ­la de &#8220;<i>undefined reference to `vtable for NombreClase::metodo()</i>&#8216;&#8221; en los lugares de la aplicaciÃ³n de prueba que se usaba la biblioteca).</p>
<p>Pero, Â¿por quÃ©? Inicialmente pensÃ© que tal vez habrÃ­a que hacer algo mÃ¡s que aÃ±adir la opciÃ³n <i>SHARED</i> en el objetivo para crear la biblioteca (&#8220;<i>kde4_add_library(ktutorial SHARED ${ktutorial_LIB_SRCS})</i>&#8220;) y por ese motivo fallaba. Sin embargo, el amigo Google no me devolvÃ­a nada concluyente a este respecto. SegÃºn parecÃ­a, con aÃ±adir esa opciÃ³n ya era suficiente para crear la biblioteca.</p>
<p>AsÃ­ que busquÃ© en las kdelibs algÃºn archivo de CMake que generase una biblioteca dinÃ¡mica, para ver si habÃ­a algo que se me escapase. La mayorÃ­a eran archivos &#8220;grandes&#8221;, aunque buscando, lleguÃ© al archivo de CMake para <i>kdelibs/kde3support/kunittest</i>. Generaba una biblioteca y un ejecutable que enlazaba con Ã©sta, era pequeÃ±o y fÃ¡cil de entender. Â¡Excelente!</p>
<p>O no tanto. Porque resulta que el archivo de CMake tenÃ­a lo mismo que los que utilizaba yo. Tras varias pruebas, entre ellas aislar esa biblioteca y generarla de 0 (por si acaso CMake utilizaba objetivos heredados de los directorios padre) y ver que funcionaba, supuse que el problema no estarÃ­a en los objetivos de CMake. Pero, Â¿dÃ³nde entonces?</p>
<p>PensÃ© que el problema podÃ­a residir en que la biblioteca dinÃ¡mica enlazaba con una biblioteca estÃ¡tica temporal. Esta biblioteca estÃ¡tica simplemente contiene las clases de la vista, que estÃ¡n separadas del modelo en un subdirectorio. Me parecÃ­a extraÃ±o que fuese el problema, ya que anteriormente habÃ­a trabajado con un esquema similar, aunque en una biblioteca que no era de KDE, y no presentaba problemas. Pero como no sabÃ­a dÃ³nde buscar, intentÃ© por ese lado. Y como era de esperar&#8230; seguÃ­a sin funcionar.</p>
<p>Puestos a dar palos de ciego, decidÃ­ enlazar la biblioteca no con una aplicaciÃ³n de verdad, sino con la mÃ­nima expresiÃ³n de un programa de C++, a ver quÃ© pasaba. AsÃ­ que hice simplemente un mÃ©todo main que crease un objeto de una clase de la biblioteca. EnlacÃ© y&#8230; Â¡funcionÃ³! Por probar, cree un objeto de otra clase, y enlacÃ© de nuevo. Y esta vez, fallaba al enlazar con el nuevo objeto. Ni que decir tiene que miraba incrÃ©dulo a la pantalla, esperando que mi querido ordenador sacase un diÃ¡logo llamÃ¡ndome inocente y diciÃ©ndome que ya paraba con la broma.</p>
<p>Pero en vista de que eso no ocurrÃ­a, decidÃ­ mirar dÃ³nde estaba la diferencia entre ambas clases, para que una enlazase y la otra no. Y la diferencia era que la que enlazaba era una clase normal, mientras que la que no, era derivada de QObject. Me encanta Qt, adoro todas sus caracterÃ­sticas, me emociono sÃ³lo de pensar en seÃ±ales y ranuras. Pero en ese instante quise que David el gnomo acabase con todos los trolls (por si alguien no sabe a quÃ© me refiero, Qt es obra de Trolltech, a cuyos empleados se les conoce como &#8220;los trolls&#8221;. SÃ­, es el peor intento de chiste que leÃ­ste en mucho tiempo, lo sÃ©. Pero quÃ© quieres, estoy cansado <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  ).</p>
<p>Con todo esto, decidÃ­ volver sobre el cÃ³digo de kunittest. El sistema de construcciÃ³n era igual al que yo usaba, por lo que la diferencia tenÃ­a que estar en el cÃ³digo de las clases. Lo primero que advertÃ­ era que dichas clases incluÃ­an en los cpp los archivos moc generados por la herramienta de Qt para hacer su magia.</p>
<p>No me constaba que en KDE 4 fuese necesario (aunque, hasta donde sÃ©, con KDE 3 sÃ­), pero dado que a esas alturas si alguien me decÃ­a que mi problema se solucionarÃ­a dando tres vueltas sobre mi mismo y diciendo &#8220;Oh todopoderoso enlazador yo te invoco&#8221; en arameo antes de construir la biblioteca yo lo intentarÃ­a, pues probÃ© incluyendo los archivos moc.</p>
<p>JamÃ¡s adivinarÃ­ais quÃ© pasÃ³. Exacto, siguiÃ³ sin funcionar. A punto de subirme a la silla gritando &#8220;Je suis NapolÃ©on!&#8221;, vi algo que me llamÃ³ la antenciÃ³n en un archivo .h de kunittest: &#8220;<i>class KUNITTEST_EXPORT Runner : public QObject</i>&#8220;. TenÃ­a que ser eso. MirÃ© quÃ© valor tenÃ­a la macro, y cuando se construÃ­a la biblioteca Ã©ste era &#8220;<i>KDE_EXPORT</i>&#8220;. &#8220;Eso suena a exportar sÃ­mbolos de la biblioteca&#8221;, pensÃ©.</p>
<p>AsÃ­ que hice una prueba rÃ¡pida y aÃ±adÃ­ dicha macro en la clase que utilizaba en mi main simplificado y que no enlazaba. Y un coro celestial bajÃ³ a arroparme entre cÃ¡nticos de jÃºbilo y felicidad. Â¡Â¡Â¡AL FIN!!!</p>
<p>Tras esto, hice los cambios necesarios en la biblioteca para que todas las clases derivadas directa o indirectamente de QObject utilizasen dicha macro, y todo funcionÃ³ como era de esperar <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Realmente no estoy seguro de la explicaciÃ³n tÃ©cnica de por quÃ© ocurre esto. Mis conocimientos sobre enlazado de C++ en Linux no llegan a tanto, y tampoco tengo tiempo de ponerme a investigarlo. Pero sÃ­ se la regla de oro: si haces una biblioteca dinÃ¡mica en KDE, tienes que marcar tus clases pÃºblicas para que se pueda enlazar con ellas. Para ver cÃ³mo deben marcarse, a la versiÃ³n corta del artÃ­culo me remito <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Una vez arreglado esto, a seguir con los objetivos de instalaciÃ³n de CMake para poder usar la internacionalizaciÃ³n.</p>
<p>Y tras este artÃ­culo es cuando el anterior pasa a ser claramente anacrÃ³nico, ya que no pude dedicarme la tarde entera a investigar lo narrado en Ã©l, cuando en Ã©ste se ve cÃ³mo estuve haciendo otra cosa distinta <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ktutorial.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ktutorial.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=7&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2008/02/06/bibliotecas-dinamicas-en-kde-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>AÃ±adiendo la entrada &#8220;Tutoriales&#8221; al menÃº ayuda de KDE</title>
		<link>http://ktutorial.wordpress.com/2008/02/06/anadiendo-la-entrada-tutoriales-al-menu-ayuda-de-kde/</link>
		<comments>http://ktutorial.wordpress.com/2008/02/06/anadiendo-la-entrada-tutoriales-al-menu-ayuda-de-kde/#comments</comments>
		<pubDate>Wed, 06 Feb 2008 17:11:07 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kde]]></category>
		<category><![CDATA[xmlgui]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=6</guid>
		<description><![CDATA[El siguiente artÃ­culo es un anacronismo. DeberÃ­a haberlo publicado ya hace varios dÃ­as, que fue cuando lo escribÃ­, pero no sÃ© por quÃ© no lo hice aÃºn. AsÃ­ que aquÃ­ estÃ¡, para regocijo y disfrute de pequeÃ±os y mayores  
Tras una tarde de investigaciÃ³n, lectura de cÃ³digo (ventajas del software libre   ) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=6&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>El siguiente artÃ­culo es un anacronismo. DeberÃ­a haberlo publicado ya hace varios dÃ­as, que fue cuando lo escribÃ­, pero no sÃ© por quÃ© no lo hice aÃºn. AsÃ­ que aquÃ­ estÃ¡, para regocijo y disfrute de pequeÃ±os y mayores <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Tras una tarde de investigaciÃ³n, lectura de cÃ³digo (ventajas del software libre <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) y depuraciÃ³n no encontrÃ© la manera de que una biblioteca aÃ±ada automÃ¡ticamente una entrada en un punto concreto del menÃº de ayuda de KDE de una aplicaciÃ³n que utiliza XMLGUI (que deberÃ­an ser todas).</p>
<p>Â¿Y quÃ© quiere decir todo eso? Bueno, expliquÃ©moslo un poco mÃ¡s. En KDE 4 se utiliza (por el momento al menos) una tecnologÃ­a denominada XMLGUI para crear las interfaces grÃ¡ficas de usuario de las aplicaciones. En un fichero XML se indican cÃ³mo estarÃ¡n organizados el menÃº y las barras de tareas y quÃ© acciones corresponderÃ¡n a cada elemento, y luego esas acciones se definen en el propio cÃ³digo de la aplicaciÃ³n.</p>
<p>Los archivos XML que describen la interfaz son jerÃ¡rquicos, pudiendo mezclarse con otros. De esta forma, puede tenerse un archivo que describe la interfaz comÃºn de las aplicaciones de KDE, y luego cada una de Ã©stas puede tener su propio archivo en el que se aÃ±aden nuevos elementos. La uniÃ³n (virtual, no fÃ­sica) de ambos archivos da como resultado la interfaz final.</p>
<p>La mezcla, en el caso de los menÃºs que es lo que nos ocupa, se realiza mediante los elementos Merge, MergeLocal y DefineGroup. Reconozco no tener muy claro cÃ³mo funciona el elemento Merge, principalmente porque por mÃ¡s que busquÃ©, no encontrÃ© documentaciÃ³n al respecto de los elementos, por lo que lo que sÃ© de ellos es fruto del mero anÃ¡lisis del cÃ³digo fuente y la experimentaciÃ³n.</p>
<p>En cuanto a MergeLocal, se establece en el documento padre de forma que los elementos que en el hijo pertenezcan al mismo menÃº en el que estÃ¡ se incluyan en lugar del elemento MergeLocal. En lo que respecta a DefineGroup, define la posiciÃ³n en la que se aÃ±adirÃ¡n todos los elementos pertenecientes a un determinado grupo. En el documento hijo simplemente se aÃ±ade en los elementos deseados el atributo group con el nombre del grupo en cuestiÃ³n.</p>
<p>Si no existe ninguno de estos elementos de mezcla, los nuevos elementos del documento hijo se aÃ±aden al final del menÃº al que pertenezcan.</p>
<p>El problema se presenta cuando aparece un tercer documento XML. O, mejor dicho, cuando aparece un tercer documento que deba mezclarse&#8230; en el MergeLocal del primer documento. Por ejemplo, el que indica dÃ³nde debe incluirse en el menÃº de ayuda una acciÃ³n correspondiente a una biblioteca utilizada por una aplicaciÃ³n (que, obviamente, era lo que intentaba <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).</p>
<p>El menÃº de ayuda viene definido, como era de esperar, en el documento de XMLGUI general de KDE: kdelibs/kdeui/xmlgui/ui_standards.rc. A este documento se le aÃ±ade el documento especÃ­fico de cada aplicaciÃ³n. Y a estos dos debe aÃ±adirse el documento de KTutorial, de forma que se aÃ±ada una entrada en la interfaz final en el menÃº de ayuda, y que Ã©sta lÃ³gicamente estÃ© ubicada en el espacio habilitado para la mezcla, no al final del menÃº.</p>
<p>El problema estÃ¡ en que MergeLocal sÃ³lo sirve para mezclar el documento padre con el documento hijo inmediatamente inferior. Es decir, el documento general de KDE con el documento de la aplicaciÃ³n. En KXMLGUIClientPrivate::mergeXML(&#8230;), en el archivo kxmlguiclient.cpp puede verse cÃ³mo, una vez mezclado un documento padre con el hijo, el elemento se elimina.</p>
<p>PodrÃ­a pensarse en mezclar el documento de la aplicaciÃ³n con el de la biblioteca, y luego todo ello con el general de KDE. Pero tampoco servirÃ­a. Dejando a un lado que los mÃ©todos que permitirÃ­an hacer eso son protegidos (lo que quizÃ¡s podrÃ­a salvarse con un sucio apaÃ±o en el preprocesador definiendo la cadena &#8220;protected&#8221; como &#8220;public&#8221; e incluyendo los archivos de cabecera), el principal problema reside en el cÃ³digo del mÃ©todo KXmlGuiWindow::setupGUI(), el encargado de crear la interfaz grÃ¡fica a partir de los documentos de XMLGUI.</p>
<p>En Ã©ste se carga primero el documento general de KDE, y luego Ã©ste se mezcla con el especÃ­fico de la aplicaciÃ³n. Y una vez hecho eso, ya se analizan los demÃ¡s documentos a utilizar. Te pongas como te pongas, eso es algo contra lo que no puedes luchar <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Y entonces, todo esto, Â¿en quÃ© acaba? La conclusiÃ³n es que no se puede habilitar KTutorial en una aplicaciÃ³n Ãºnicamente llamando a KTutorial::setup(), como serÃ­a deseable, sino que es necesario ademÃ¡s modificar el documento XMLGUI que utiliza, definiendo en el menÃº de ayuda el grupo ktutorial. De este modo, cuando se cargue el documento de KTutorial, los elementos definidos en Ã©ste se aÃ±adirÃ¡n al grupo, que a su vez ocuparÃ¡ la posiciÃ³n indicada en el documento general de KDE para la mezcla en el menÃº de ayuda.</p>
<p>SÃ­, ciertamente es una investigaciÃ³n muy larga para un problema tan pequeÃ±o, pero bueno, serÃ­a mejor que funcionase sin tener que aÃ±adir nada en el documento de XMLGUI, Â¿no? <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ktutorial.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ktutorial.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=6&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2008/02/06/anadiendo-la-entrada-tutoriales-al-menu-ayuda-de-kde/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
		<item>
		<title>SÃ­, de vez en cuando estÃ¡ bien actualizar</title>
		<link>http://ktutorial.wordpress.com/2008/02/04/si-de-vez-en-cuando-esta-bien-actualizar/</link>
		<comments>http://ktutorial.wordpress.com/2008/02/04/si-de-vez-en-cuando-esta-bien-actualizar/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 22:14:53 +0000</pubDate>
		<dc:creator>Kalvy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://ktutorial.wordpress.com/?p=5</guid>
		<description><![CDATA[Ya sabÃ­a yo que el blog no iba a ser lo mÃ­o  
El caso es que todo este tiempo de silencio no fue tiempo de inactividad (aunque una parte sÃ­, para quÃ© negarlo). De hecho, hace un mes que tengo un borrador de un artÃ­culo pendiente de terminar de escribir y publicar&#8230; A ver [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=5&subd=ktutorial&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ya sabÃ­a yo que el blog no iba a ser lo mÃ­o <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>El caso es que todo este tiempo de silencio no fue tiempo de inactividad (aunque una parte sÃ­, para quÃ© negarlo). De hecho, hace un mes que tengo un borrador de un artÃ­culo pendiente de terminar de escribir y publicar&#8230; A ver si estos dÃ­as lo hago, junto con algÃºn otro texto que escribÃ­ para mÃ­ mismo y que no sÃ© por quÃ© no subÃ­ aÃºn al blog.</p>
<p>Pero, Â¿en quÃ© estado estÃ¡ el proyecto? Porque en la forja tampoco es que haya mucho (por no decir ningÃºn) movimiento. En contra de lo que pudiese pensarse, el proyecto marcha <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Mis planes iniciales eran hacer unos requisitos y un anÃ¡lisis bÃ¡sicos y a partir de ahÃ­, empezar a diseÃ±ar y a implementar poco a poco. Pero la verdad es que el anÃ¡lisis y yo no nos llevamos muy bien, por decirlo suavemente. AsÃ­ que sÃ­, hice unos requisitos bÃ¡sicos&#8230; y luego se me fue la cabeza, y empecÃ© a pensar en el lenguaje de script.</p>
<p>Estuve unos dÃ­as dÃ¡ndole vueltas al tema del lenguaje, pero no avanzaba nada de nada. Lo Ãºnico que podrÃ­a decirse que descubrÃ­ es que XML no es nada apropiado para lo que querÃ­a hacer en un principio, asÃ­ que tendrÃ© que replantearme esa parte. Pero salvo esa conclusiÃ³n, la cosa no marchaba.</p>
<p>Hasta que, un dÃ­a, volviendo de clase en el autobÃºs, adormilado, tuve una revelaciÃ³n. AlcancÃ© el Nirvana de KTutorial, y vi claramente que el enfoque que estaba siguiendo era errÃ³neo. No tengo pruebas grÃ¡ficas, pero creo que en aquel momento tuve un aura dorada visible alrededor de mÃ­. Vale, sÃ­, quizÃ¡s estÃ© exagerando un poco&#8230;</p>
<p>El caso es que, en lugar de darle vueltas al lenguaje de script, me di cuenta de que lo mejor era olvidarse de Ã©l temporalmente, y centrarme en crear el framework en sÃ­ que utilizarÃ­a. Y eso es lo que hice.</p>
<p>(AquÃ­ irÃ­an una serie de acontecimientos ciertamente irrelevantes y que no harÃ­an mÃ¡s que alargar un ya de por sÃ­ insulso artÃ­culo, por lo que elegantemente me lo salto).</p>
<p>A dÃ­a de hoy, el framework estÃ¡ prÃ³ximo a una versiÃ³n inicial digna. En esta versiÃ³n inicial los tutoriales tienen que estar hechos en C++ y compilados con la propia aplicaciÃ³n a la que pertenezcan en lugar de ser scripts, pero ya habrÃ¡ tiempo de dar soporte tambiÃ©n a scripts en prÃ³ximas versiones.</p>
<p>Quedan acometer una serie de puntos, como son verificar el funcionamiento de la internacionalizaciÃ³n, escribir los objetivos de instalaciÃ³n para CMake (el sistema de construcciÃ³n de KDE 4) y habilitar pruebas unitarias, que harÃ© en los prÃ³ximos dÃ­as (ya, las pruebas unitarias hubiesen estado mejor creadas de antemano <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ).</p>
<p>Cuando eso estÃ© listo, subirÃ© una versiÃ³n inicial a la forja y comenzarÃ© a trabajar sobre su SVN (ahora mismo estoy con un SVN local). Si no lo hago aÃºn es porque prefiero que la primera versiÃ³n disponible sea algo digno. Meras manÃ­as <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Y asÃ­ estÃ¡n las cosas. Una vez termine el parÃ³n por los exÃ¡menes de febrero (que ya estÃ¡n ahÃ­, y habrÃ¡ que dedicarles algo de tiempo <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) me meterÃ© con alguna de las tareas de mi TODO&#8230; Pero sobre eso ya habrÃ¡ tiempo de escribir.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/ktutorial.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/ktutorial.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ktutorial.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ktutorial.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/ktutorial.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/ktutorial.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/ktutorial.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/ktutorial.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/ktutorial.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/ktutorial.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/ktutorial.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/ktutorial.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=ktutorial.wordpress.com&blog=2240231&post=5&subd=ktutorial&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://ktutorial.wordpress.com/2008/02/04/si-de-vez-en-cuando-esta-bien-actualizar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/554b6a881ccff08792b2aabe64081eaa?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Kalvy</media:title>
		</media:content>
	</item>
	</channel>
</rss>