<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.shadoware.org/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Shadoware.Org - Mot-clé - planet</title>
  <link>http://www.shadoware.org/</link>
  <atom:link href="http://www.shadoware.org/index.php/feed/tag/planet/rss2" rel="self" type="application/rss+xml"/>
  <description>Moi, mes idées, mes logiciels ...</description>
  <language>fr</language>
  <pubDate>Mon, 06 Feb 2012 15:38:11 +0100</pubDate>
  <copyright>Ulrich VANDENHEKKE</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>KMDAlert - Logiciel de surveillance de périphérique RAID - Version pour KDE 4.0</title>
    <link>http://www.shadoware.org/post/kmdalert-0.2</link>
    <guid isPermaLink="false">urn:md5:34b6a6d32b5e50755d5fe92a063ea2be</guid>
    <pubDate>Sun, 14 Aug 2011 20:43:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>KMDAlert</category>
        <category>kde</category><category>kmdalert</category><category>libre</category><category>mdadm</category><category>planet</category><category>raid</category><category>systray</category>    
    <description>    &lt;h2&gt;Présentation&lt;/h2&gt;


&lt;p&gt;Possédant chez moi des disques durs en RAID logiciels sous Gnu/Linux, en 2007 (cela fait déjà 4 ans), &lt;a href=&quot;http://www.shadoware.org/post/kmdalert&quot;&gt;j'avais écrit un petit logiciel&lt;/a&gt; dont le but était de faire du monitoring RAID.&lt;/p&gt;


&lt;p&gt;En cas de reconstruction du RAID ou de  disque défectueux, le logiciel affiche une notification à l'utilisateur, et change le statut affiché dans la barre de notification (&lt;em&gt;systray&lt;/em&gt;). L'icône change bien sur en fonction de l'état du RAID&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;dégradé (avec un point d'exclamation)&lt;/li&gt;
&lt;li&gt;en cours de synchronisation (avec une barre de progression)&lt;/li&gt;
&lt;li&gt;disque RAID dans un état normal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ce logiciel ne tournait que sous KDE 3.X.&lt;/p&gt;


&lt;p&gt;Voici donc une nouvelle version (qui a mis le temps de sortir) qui est un portage de l'application sous KDE 4.X. Elle utilise donc le nouveau système de notification de KDE (pour l'instant en passant uniquement par les notifications standard). Quelques améliorations y seront apportées plus tard.&lt;/p&gt;


&lt;h2&gt;Requis&lt;/h2&gt;


&lt;p&gt;Pour fonctionner &lt;em&gt;KMDAlert&lt;/em&gt; nécessite que le dossier &lt;code&gt;/sys&lt;/code&gt; soit monté et que &lt;code&gt;/sys/block/&lt;/code&gt; soit renseigné pour chaque volume RAID (exemple &lt;code&gt;/sys/block/md0&lt;/code&gt;, &lt;code&gt;/sys/block/md1&lt;/code&gt;, ...). &lt;code&gt;KMDAlert&lt;/code&gt; observe ensuite les modifications faites sur les fichiers pour informer l'utilisateur des modifications faites sur le volume RAID ou sur les disques le composant.&lt;/p&gt;


&lt;p&gt;De nos jours le dossier &lt;code&gt;/sys&lt;/code&gt; et &lt;code&gt;/sys/block&lt;/code&gt; devraient être toujours présents.&lt;/p&gt;


&lt;p&gt;L'application a été développée sur &lt;em&gt;Gnu/Debian Squeeze&lt;/em&gt;, sur un KDE 4.4.5 avec un noyau 2.6.32.&lt;/p&gt;


&lt;p&gt;&lt;em&gt;KMDAlert&lt;/em&gt; ne nécessite pas de &lt;em&gt;Inotify&lt;/em&gt;. &lt;em&gt;KMDAlert&lt;/em&gt; lit le contenu de plusieurs fichiers dans le dossier &lt;code&gt;/sys&lt;/code&gt; toutes les 6 secondes pour être informé de la modification de l'état du périphérique. Sur l'application d'origine, développé sous un noyau 2.6.18, &lt;em&gt;Inotify&lt;/em&gt; n'est pas averti des modifications faites sur le système de fichier &lt;code&gt;/sys&lt;/code&gt;. Les dates de ces fichiers ne sont pas non plus modifiées. Si quelqu'un a une autre méthode à me proposer, je reste ouvert à toutes propositions.&lt;/p&gt;


&lt;p&gt;&lt;em&gt;KMDAlert&lt;/em&gt; est une application écrite en utilisant les librairies de KDE, mais devrait tout de même fonctionner sous Gnome. Les messages de notification utilisent donc le système de notification de KDE (bien que je n'utilise pas toutes ses possibilités).&lt;/p&gt;


&lt;h2&gt;Compilation / Installation&lt;/h2&gt;


&lt;p&gt;La compilation et l'installation de &lt;em&gt;KMDAlert&lt;/em&gt; se fait à l'aide du trio habituel&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Décompression de KMDAlert&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;tar&lt;/span&gt; xjfv kmdalert-&lt;span style=&quot;color: #000000;&quot;&gt;0.2&lt;/span&gt;-77c0d6b4d49f.tar.gz
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; kmdalert-77c0d6b4d49f
&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Préparation de la compilation&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; build
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; build
&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Comilation&lt;/span&gt;
cmake ..&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Installation&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;La compilation nécessite les librairies de développement KDE et Qt3, ainsi que le compilateur GCC.&lt;/p&gt;


&lt;h2&gt;Licence&lt;/h2&gt;


&lt;p&gt;La licence choisie est la  &lt;a href=&quot;http://www.gnu.org/licenses/gpl-2.0.txt&quot; hreflang=&quot;en&quot; title=&quot;GNU GENERAL PUBLIC LICENCE&quot;&gt;GNU GENERAL PUBLIC LICENSE&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;Téléchargement&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vous pouvez télécharger une archive déjà construite de l'application sur &lt;a href=&quot;http://kde-apps.org/content/show.php/KMDAlert?content=73373&quot; hreflang=&quot;fr&quot;&gt;KDE-Apps.org&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Le dépôt officiel pour télécharger les sources et participer&amp;nbsp;: &lt;a href=&quot;http://hg.shadoware.org/kmdalert?pk_campaign=shadoware&quot;&gt;http://hg.shadoware.org/kmdalert&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Vous pouvez également télécharger la version attachée au billet.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Système de suivi&lt;/h2&gt;


&lt;p&gt;Il n'y a actuellement plus de système de suivi pour ce logiciel. En cas de problème, vous pouvez laisser un message dans les commentaires ou m'envoyer un mail.&lt;/p&gt;</description>
    
          <enclosure url="http://www.shadoware.org/public/download/kmdalert/kmdalert-0.2-77c0d6b4d49f.tar.gz"
      length="50726" type="application/x-gzip" />
    
    
          <comments>http://www.shadoware.org/post/kmdalert-0.2#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/kmdalert-0.2#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/674</wfw:commentRss>
      </item>
    
  <item>
    <title>[C++/Qt] CMake et Qt</title>
    <link>http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt</link>
    <guid isPermaLink="false">urn:md5:da05e097d1a727105b6e5727b3bb6c22</guid>
    <pubDate>Sun, 26 Jun 2011 14:41:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>C++</category>
        <category>cmake</category><category>planet</category><category>qmake</category><category>qt</category>    
    <description>&lt;p&gt;Suite à un &lt;a href=&quot;http://www.shadoware.org/post/2008/01/21/42-qabstractitemmodel-qt&quot;&gt;billet&lt;/a&gt; datant de 2008, je reviens vers vous pour ajouter quelques précisions sur la compilation de programme &lt;a href=&quot;http://qt.nokia.com/&quot;&gt;Qt&lt;/a&gt; avec &lt;a href=&quot;http://www.cmake.org/&quot;&gt;CMake&lt;/a&gt;. En effet, pour mon programme &lt;a href=&quot;http://xinx.shadoware.org?piwik_campaign=Shadoware&amp;amp;piwik_keyword=Billet CMake et Qt&quot;&gt;XINX&lt;/a&gt;, j'ai modifié la chaîne de compilation actuelle utilisant &lt;em&gt;QMake&lt;/em&gt; par une chaîne de compilation &lt;em&gt;CMake&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;&lt;em&gt;CMake&lt;/em&gt; est un puissant générateur de &lt;code&gt;Makefile&lt;/code&gt;, il permet de remplacer les anciens (mais pas complètement révolus) &lt;a href=&quot;http://www.gnu.org/software/autoconf/&quot;&gt;autotools&lt;/a&gt;. &lt;em&gt;CMake&lt;/em&gt; ne remplace donc pas le programme &lt;code&gt;make&lt;/code&gt; mais vient se placer en amont.&lt;/p&gt;


&lt;p&gt;&lt;em&gt;CMake&lt;/em&gt; permet de compiler un programme à  différents endroits du dossier des sources, ce qui permet de garder le répertoire des sources &lt;em&gt;propre&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Nous allons considérer dans la suite le dossier &lt;code&gt;projet&lt;/code&gt; suivant&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;projet&lt;/code&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;source&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;build&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;    &lt;h3&gt;Compilation&lt;/h3&gt;


&lt;p&gt;Nous passerons sous silence la compilation d'un programme non &lt;em&gt;Qt&lt;/em&gt; qui peut être retrouvé dans la &lt;a href=&quot;http://www.cmake.org/cmake/help/cmake_tutorial.html&quot;&gt;documentation&lt;/a&gt; et nous nous limiterons aux explications liées aux programmes écrits en ''Qt' (qui peuvent également être retrouvés dans d'autres tutoriels sur Internet).&lt;/p&gt;


&lt;h4&gt;Package à utiliser&lt;/h4&gt;


&lt;p&gt;Pour utiliser &lt;em&gt;Qt4&lt;/em&gt; avec &lt;em&gt;CMake&lt;/em&gt;, il faut inclure le package &lt;code&gt;Qt4&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:project&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;project&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;lenomdemonprojet&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt; 
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:cmake_minimum_required&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;cmake_minimum_required&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;VERSION&lt;/span&gt; 2.8.0&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:find_package&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;find_package&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;Qt4 REQUIRED&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Définir les modules Qt à utiliser&amp;nbsp;:&lt;/h4&gt;


&lt;p&gt;Il est ensuite possible d'activer ou de désactiver les différents modules de &lt;em&gt;Qt&lt;/em&gt; à utiliser suivant le programme que vous écrivez&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_DONT_USE_QTCORE &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_DONT_USE_QTGUI &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QT3SUPPORT &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTASSISTANT &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QAXCONTAINER &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QAXSERVER &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTDESIGNER &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTMOTIF &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTMAIN &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTNETWORK &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTNSPLUGIN &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTOPENGL &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTSQL &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTXML &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTXMLPATTERNS &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTWEBKIT &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTSVG &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTTEST &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTUITOOLS &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTDBUS &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTSCRIPT &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTASSISTANTCLIENT &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTHELP &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_PHONON &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Par exemple pour faire un programme utilisant le module Xml, XmlPatterns, et Webkit il faut ajouter&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTXML &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTXMLPATTERNS &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;QT_USE_QTWEBKIT &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;TRUE&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Quelques déclarations supplémentaires&lt;/h4&gt;


&lt;p&gt;Après avoir compilé les différentes parties du programme avec le générateur de &lt;code&gt;Makefile&lt;/code&gt; de &lt;em&gt;Qt&lt;/em&gt; (QMake), j'ai relevé les différentes définitions à ajouter lors de la compilation. De plus une fois les modules définis, il faut inclure également le module &lt;em&gt;UseQt4&lt;/em&gt;.&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DUNICODE&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Les Q_ASSERT, Q_ASSERT_X, ... sont désactivés en mode Release&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:if&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;if&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;CMAKE_BUILD_TYPE &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;STREQUAL&lt;/span&gt; &lt;span style=&quot;color: #912f11;&quot;&gt;&amp;quot;Release&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
	&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DQT_NO_DEBUG&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endif&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endif&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;()&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Include utilisé par Qt (du style include (UseQt4))&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:include&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;include&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b08000;&quot;&gt;${QT_USE_FILE}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# Ajoute les définitions propres à Qt (suivant les modules ajoutés)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b08000;&quot;&gt;${QT_DEFINITIONS}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Macros pour générer les fichiers &lt;code&gt;moc&lt;/code&gt;.&lt;/h4&gt;


&lt;h5&gt;Macro par défaut&lt;/h5&gt;


&lt;p&gt;La facilité de programmation en &lt;em&gt;Qt&lt;/em&gt; est due à l'ajout par le framework de la notion de méta-objet. Cette notion se fait à l'aide d'un générateur propre à ce framework&amp;nbsp;: &lt;code&gt;moc&lt;/code&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt#pnote-636-1&quot; id=&quot;rev-pnote-636-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Pour générer les méta-objets, il faut définir sur les objets descendants de &lt;code&gt;QObject&lt;/code&gt;, une macro &lt;code&gt;Q_OBJECT&lt;/code&gt;. Cette macro ajoute, côté interface, la déclaration de méthodes supplémentaires pour la gestion des méta-informations, et coté implémentation, ajoute l'implémentation de ces méta-informations ainsi que la déclaration des signaux et de slots de l'objet&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt#pnote-636-2&quot; id=&quot;rev-pnote-636-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Pour générer les fichiers d'implémentation générés par le compilateur &lt;code&gt;moc&lt;/code&gt;, il est possible d'utiliser la macro suivante pour une liste de fichier sources (extension .cpp, ou .cxx, ...)&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;qt4_wrap_cpp&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;outfiles inputfile ... OPTIONS ...&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cette macro générera un fichier de type &lt;code&gt;moc_nomfichier.cxx&lt;/code&gt; qu'il faudra inclure dans le ficher CPP (car il n'est pas inclus automatiquement dans la liste des fichiers à compiler.&lt;/p&gt;
&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;quot;moc_nomfichier.cxx&amp;quot;&lt;/span&gt;&lt;/pre&gt;


&lt;h5&gt;Une autre macro&lt;/h5&gt;


&lt;p&gt;Autre possibilité, faire comme avec les fichiers &lt;code&gt;.pro&lt;/code&gt; de &lt;em&gt;QMake&lt;/em&gt; et générer un fichier moc pour chaque fichier &lt;code&gt;.h&lt;/code&gt; possédant une macro &lt;code&gt;Q_OBJECT&lt;/code&gt;. Pour cela j'ai écrit la petite macro suivante&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:macro&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;macro&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;xinx_automoc outfiles&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
  qt4_get_moc_flags&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;moc_flags&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
  qt4_extract_options&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;moc_files moc_options &lt;span style=&quot;color: #b08000;&quot;&gt;${ARGN}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&amp;nbsp;
  &lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:foreach&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;foreach&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;it &lt;span style=&quot;color: #b08000;&quot;&gt;${moc_files}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
    &lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:get_filename_component&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;get_filename_component&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;it &lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; ABSOLUTE&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&amp;nbsp;
    &lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:if&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;if&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;EXISTS&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; &lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
		&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:file&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;file&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;READ &lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; _contents&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&amp;nbsp;
		&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:string&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;string&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;REGEX&lt;/span&gt; &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;MATCHALL&lt;/span&gt; &lt;span style=&quot;color: #912f11;&quot;&gt;&amp;quot;Q_OBJECT&amp;quot;&lt;/span&gt; _match &lt;span style=&quot;color: #912f11;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #b08000;&quot;&gt;${_contents}&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
		&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:if&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;if&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;_match&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
			qt4_make_output_file&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; moc_ cxx outfile&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
			qt4_create_moc_command&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${outfile}&lt;/span&gt; &lt;span style=&quot;color: #912f11;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #b08000;&quot;&gt;${moc_flags}&lt;/span&gt;&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #912f11;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #b08000;&quot;&gt;${moc_options}&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
			macro_add_file_dependencies&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${outfile}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
			&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #b08000;&quot;&gt;${outfiles}&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${${outfiles}&lt;/span&gt;} &lt;span style=&quot;color: #b08000;&quot;&gt;${outfile}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
		&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endif&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endif&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;_match&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
    &lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endif&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endif&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt; &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;EXISTS&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${it}&lt;/span&gt; &lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
  &lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endforeach&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endforeach&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;it&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endmacro&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endmacro&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;xinx_automoc&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Elle s'utilise ainsi&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;xinx_automoc&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;moc_headers &lt;span style=&quot;color: #b08000;&quot;&gt;${headers}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Macro pour générer les fichiers en tête d'interface graphique.&lt;/h4&gt;


&lt;p&gt;Les interfaces graphiques sont développées à l'aide de &lt;em&gt;Qt-Designer&lt;/em&gt;. Ces fichiers sont au format XML.&lt;/p&gt;


&lt;p&gt;La macro CMake suivante permet de transformer ces fichiers XML en fichier d'entête C.&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;qt4_wrap_ui&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;outfiles inputfile ...&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Macro pour compiler les fichiers de resources&lt;/h4&gt;


&lt;p&gt;La macro CMake suivante permet de compiler le fichier de ressource (extension *.qrc) en fichier &lt;code&gt;cpp&lt;/code&gt; qui sera ensuite compilé avec le reste du programme&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;qt4_add_resources&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;outfiles inputfile ... OPTIONS ...&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Macro pour compiler les fichiers de traduction&lt;/h4&gt;


&lt;p&gt;La macro CMake suivante est utilisée pour compiler un fichier de traduction &lt;code&gt;ts&lt;/code&gt; en fichier de traduction compilé &lt;code&gt;qm&lt;/code&gt;. Ce dernier est ensuite à inclure dans le programme (soit par un fichier de ressource, soit dans un dossier à coté).&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;qt4_add_translation&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;qm_files ts_files ...&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Compilation d'un plugin&lt;/h4&gt;


&lt;p&gt;En plus des options décrites ci-dessus, pour compiler un plugin, il faut ajouter quelques définitions supplémentaires.&lt;/p&gt;


&lt;p&gt;Il faut bien faire attention à ce que le plugin soit compilé en mode &lt;code&gt;Release&lt;/code&gt; si le programme l'est aussi (Ce qui n'est pas forcément pratique pour faire du debug).&lt;/p&gt;


&lt;h5&gt;Plugin dynamique&lt;/h5&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DQT_PLUGIN&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DQT_SHARED&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_library&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;webplugin &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;SHARED&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${webplugin_SRCS}&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${webplugin_MOC_SRCS}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h5&gt;Plugin Static&lt;/h5&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DQT_PLUGIN&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DQT_STATICPLUGIN&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:if&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;if&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;CMAKE_SIZEOF_VOID_P &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;MATCHES&lt;/span&gt; 8&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
	&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-fPIC&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endif&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endif&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;()&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_library&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;webplugin &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;STATIC&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${webplugin_SRCS}&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${webplugin_MOC_SRCS}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Ajout d'un fichier RC pour windows&lt;/h4&gt;


&lt;p&gt;Les fichiers RC Windows contiennent des informations, comme par exemple, la version et le nom du programme.&lt;/p&gt;


&lt;p&gt;Ces informations peuvent être utilisées par les programmes d'installation sous Windows ou aussi par Windows lui-même.&lt;/p&gt;


&lt;p&gt;Afin de pouvoir ajouter un fichier RC file au programme, on peut ajouter ceci&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:if&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;if&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;MINGW&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
	&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;CMAKE_RC_COMPILER_INIT windres&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
	&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:enable_language&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;enable_language&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;RC&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
	&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:set&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;set&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;CMAKE_RC_COMPILE_OBJECT &lt;span style=&quot;color: #912f11;&quot;&gt;&amp;quot;&amp;lt;CMAKE_RC_COMPILER&amp;gt; &amp;lt;FLAGS&amp;gt; &amp;lt;DEFINES&amp;gt; -O coff -o &amp;lt;OBJECT&amp;gt; &amp;lt;SOURCE&amp;gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:endif&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;endif&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;MINGW&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ensuite le fichier RC se compile comme tout autre fichier (&lt;code&gt;C++&lt;/code&gt;, ...)&lt;/p&gt;



&lt;h4&gt;Compilation d'une librairie static&lt;/h4&gt;

&lt;pre class=&quot;cmake cmake&quot; style=&quot;font-family:inherit&quot;&gt;&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_definitions&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_definitions&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;-DQT_SHARED&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;
&lt;a href=&quot;http://www.cmake.org/cmake/help/cmake2.6docs.html#command:add_library&quot;&gt;&lt;span style=&quot;color: #1f3f81; font-style: bold;&quot;&gt;add_library&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;(&lt;/span&gt;xinxplugins &lt;span style=&quot;color: #077807; font-sytle: italic;&quot;&gt;STATIC&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${xinxplugins_SRCS}&lt;/span&gt; &lt;span style=&quot;color: #b08000;&quot;&gt;${xinxplugins_MOC_SRCS}&lt;/span&gt;&lt;span style=&quot;color: #197d8b;&quot;&gt;)&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;Utiliser le programme CMake&lt;/h3&gt;


&lt;p&gt;Une fois le programme configuré, il est possible de compiler ce dernier à l'aide des commandes suivantes&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; build
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; build
&amp;nbsp;
cmake ..&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;sources
&amp;nbsp;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Sous Windows, il est possible de compiler en utilisant &lt;a href=&quot;http://www.mingw.org/&quot;&gt;MinGW&lt;/a&gt; pour compiler ou d'utiliser le compilateur de &lt;code&gt;Visual Studio&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Il est également possible de définir un emplacement pour l'installation différent du dossier par défaut&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;cmake -DCMAKE_INSTALL_PREFIX=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;home&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;login&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt#rev-pnote-636-1&quot; id=&quot;pnote-636-1&quot;&gt;1&lt;/a&gt;] C'est ce qui fait tout l'avantage de &lt;em&gt;Qt&lt;/em&gt; mais est aussi son inconvénient car il ajoute une couche supplémentaire. C'est ensuite une question de goût.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt#rev-pnote-636-2&quot; id=&quot;pnote-636-2&quot;&gt;2&lt;/a&gt;] facilitant la gestion des évènements dans &lt;em&gt;Qt&lt;/em&gt;&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/%5BQt%5D-CMake-et-Qt#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/636</wfw:commentRss>
      </item>
    
  <item>
    <title>[C++/Qt] Performance de l'utilisation de QSharedPointer</title>
    <link>http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer</link>
    <guid isPermaLink="false">urn:md5:f477dcc0189d180d38c2a61076493790</guid>
    <pubDate>Tue, 25 Jan 2011 12:00:00 +0100</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Performances</category>
        <category>kde</category><category>nokia</category><category>performance</category><category>planet</category><category>qmake</category><category>qt</category><category>trolltech</category>    
    <description>&lt;h3&gt;Présentation&lt;/h3&gt;


&lt;p&gt;&lt;em&gt;Qt&lt;/em&gt; est un framework orienté objet écrit en C++ et permettant de faire des interfaces graphiques. Ce framework est utilisé par le projet &lt;em&gt;KDE&lt;/em&gt; depuis ses débuts pour en faire un environnement de bureau très complet.&lt;/p&gt;


&lt;p&gt;&lt;em&gt;Qt&lt;/em&gt; fournit un ensemble de pointeur &lt;em&gt;intelligent&lt;/em&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-1&quot; id=&quot;rev-pnote-628-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt; permettant de gérer plus facilement la mémoire. Le but est alors de ne plus avoir à supprimer des objets. La suppression se fera soit par un pointeur &lt;em&gt;intelligent&lt;/em&gt; soit par le système de hiérarchie d'objet existant en &lt;em&gt;Qt&lt;/em&gt; (l'objet père qui supprime l'ensemble des objets fils qui lui sont rattachés).&lt;/p&gt;


&lt;p&gt;&lt;em&gt;Qt&lt;/em&gt; propose l'ensemble des pointeurs &lt;em&gt;intelligents&lt;/em&gt; suivants:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://doc.qt.nokia.com/4.6/qshareddatapointer.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation Qt de QSharedDataPointer&quot;&gt;QSharedDataPointer&lt;/a&gt; / &lt;a href=&quot;http://doc.qt.nokia.com/4.6/qshareddata.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation Qt de QSharedData&quot;&gt;QSharedData&lt;/a&gt;&amp;nbsp;: ces deux classes utilisées ensemble permettent d'écrire un objet avec partage implicite. Cela signifie que l'objet fonctionnera comme la classe &lt;em&gt;QString&lt;/em&gt;. Tant que l'objet est copié, passé en paramètre, .... l'objet n'est pas dupliqué (tous les objets pointes vers le même espace mémoire). Au moment où l'objet est modifié, l'objet est dupliqué. C'est ce qu'on appelle le COW&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-2&quot; id=&quot;rev-pnote-628-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://doc.qt.nokia.com/4.6/qexplicitlyshareddatapointer.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation Qt de QExplictlySharedDataPointer&quot;&gt;QExplictlySharedDataPointer&lt;/a&gt; / &lt;a href=&quot;http://doc.qt.nokia.com/4.6/qshareddata.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation Qt de QSharedData&quot;&gt;QSharedData&lt;/a&gt;&amp;nbsp;: QExplicitlySharedDataPointer est une variante de QSharedDataPointer. Ce pointeur &lt;em&gt;intelligent&lt;/em&gt;, comme son nom l'indique, est détaché uniquement lorsque la méthode detach() est appelée explicitement. Cette classe permet de faire des objets qui fonctionnent comme des pointeurs mais qui sont utilisés sans la notion de pointeur (le *). La suppression des données partagées se fait donc quand tous les objets ne sont plus utilisés.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://doc.qt.nokia.com/4.6/qscopedpointer.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation Qt de QScopedPointer&quot;&gt;QScopedPointer&lt;/a&gt;&amp;nbsp;: Ce pointeur est le plus simple. Il permet de déclarer un pointeur sur le tas et s'occupe de la destruction de l'objet, lorsque le programme sort de la portée du bloc. Cela permet de ne plus se soucier de la libération du pointeur dans les cas d'erreur (exception, retour avant la fin de la fonction car le fichier n'a pu être ouvert, ...).&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://doc.qt.nokia.com/4.6/qsharedpointer.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation Qt de QSharedPointer&quot;&gt;QSharedPointer&lt;/a&gt;&amp;nbsp;: Le pointeur dont on parlera dans la suite de ce billet. Il permet de partager non plus des données (comme le fait QSharedData) mais de partager un pointeur&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-3&quot; id=&quot;rev-pnote-628-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt;. Nous allons voir dans la suite du billet, comment simplement utiliser ce pointeur, et les performances de ce pointeur par rapport à un pointeur standard.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Sommaire&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#utilisation_qsharedpointer&quot;&gt;Utilisation de QSharedPointer&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#a_quoi_sert_il&quot;&gt;A quoi sert-il ?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#comment_l_utiliser&quot;&gt;Comment l'utiliser ?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#comment_utiliser_this&quot;&gt;Comment utiliser this&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#comment_eviter_les_references_circulaires&quot;&gt;Comment éviter les références circulaires&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#utilisation_dans_les_applications_multi_thread&quot;&gt;Utilisation dans les applications multi-thread.&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#utilisation_d_un_pool&quot;&gt;Utilisation d'un pool&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#benchmark&quot;&gt;Benchmark&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#code_source&quot;&gt;Code source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#le_jeu_de_test&quot;&gt;Le jeu de test&lt;/a&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#test_de_l_allocation&quot;&gt;Test de l'allocation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#test_de_modification_d_une_donnee&quot;&gt;Test de Modification d'une donnée&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#test_d_affectation&quot;&gt;Test d'affectation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#test_de_destruction&quot;&gt;Test de destruction&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#resultat_du_test&quot;&gt;Résultat du test&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-1&quot; id=&quot;pnote-628-1&quot;&gt;1&lt;/a&gt;] en anglais : smart-pointer&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-2&quot; id=&quot;pnote-628-2&quot;&gt;2&lt;/a&gt;] COW = Copy On Write&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-3&quot; id=&quot;pnote-628-3&quot;&gt;3&lt;/a&gt;] Ce pointeur est l'équivalent du pointeur &lt;em&gt;intelligent&lt;/em&gt; &lt;a href=&quot;http://www.boost.org/doc/libs/1_45_0/libs/smart_ptr/shared_ptr.htm&quot; hreflang=&quot;en&quot;&gt;boost::shared_ptr&lt;/a&gt; du projet &lt;a href=&quot;http://www.boost.org/&quot; hreflang=&quot;en&quot;&gt;Boost&lt;/a&gt;. Boost est une librairie qui ajoute beaucoup de facilité pour les programmes en C++, comme par exemple les smart-pointer dont certains seront inclus dans C++0x, ou de la boucle &lt;code&gt;std::for_each&lt;/code&gt;.&lt;/p&gt;&lt;/div&gt;
    &lt;p&gt;&lt;a name=&quot;utilisation_qsharedpointer&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Utilisation de QSharedPointer&lt;/h3&gt;


&lt;p&gt;&lt;a name=&quot;a_quoi_sert_il&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;A quoi sert-il&amp;nbsp;?&lt;/h4&gt;


&lt;p&gt;L'objet &lt;code&gt;QSharedPointer&lt;/code&gt; fait partie des pointeurs &lt;em&gt;intelligents&lt;/em&gt;. Ces pointeurs permettent de gérer automatiquement la libération de la mémoire (plus besoin de faire &lt;code&gt;delete ptr;&lt;/code&gt; quand le pointeur n'est plus utilisé) tout en restant utilisable comme un pointeur normal.&lt;/p&gt;


&lt;p&gt;&lt;code&gt;QSharedPointer&lt;/code&gt; fonctionne par comptage de référence. Après la déclaration, à chaque affectation, on augmente le compteur de référence, lorsqu'on quitte la portée du bloc, on décrémente le compteur de référence. &lt;code&gt;QSharedPointer&lt;/code&gt; détruit donc automatiquement le pointeur quand il n'existe plus aucune référence vers ce pointeur. &lt;code&gt;QSharedPointer&lt;/code&gt; vient donc comme une encapsulation de notre pointeur.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qsharedpointer/QSharedPointer1.png&quot; alt=&quot;QSharedPointer1.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;QSharedPointer1.png, janv. 2011&quot; /&gt;&lt;/p&gt;


&lt;p&gt;&lt;a name=&quot;comment_l_utiliser&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Comment l'utiliser&amp;nbsp;?&lt;/h4&gt;


&lt;p&gt;La déclaration d'un pointeur en C, se fait en écrivant &lt;code&gt;MyObject*&lt;/code&gt;. La syntaxe en utilisant un QSharedPointer se fait en écrivant &lt;code&gt;QSharedPointer&amp;lt;MyObject&amp;gt;&lt;/code&gt;. Par la suite dans le programme, l'utilisation du pointeur &lt;code&gt;QSharedObject&lt;/code&gt; se fera de la même manière qu'un pointeur C. (Avec l'opérateur &lt;code&gt;-&amp;gt;&lt;/code&gt; pour appeler un membre, une méthode, ...) . Appelons dans la suite pointeur C, les pointeurs standards et &lt;code&gt;QSharedPointer&lt;/code&gt;, le pointeur intelligent.&lt;/p&gt;


&lt;p&gt;Afin d'éviter d'avoir un pointeur normal pouvant être supprimé à tout moment dans l'application, lors de l'utilisation de &lt;code&gt;QSharedPointer&lt;/code&gt;, il ne faut utiliser le pointeur C résultant du &lt;code&gt;new&lt;/code&gt; que pour la création du &lt;code&gt;QSharedPointer&lt;/code&gt;. On peut donc directement créer le &lt;code&gt;QSharedPointer&lt;/code&gt; en utilisant le constructeur &lt;code&gt;QSharedPointer ( T * ptr )&lt;/code&gt; qui prend en paramètre le pointeur C. C'est entre ces parenthèses que nous allons créer le pointeur C&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-1&quot; id=&quot;rev-pnote-628-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #666666;&quot;&gt;// Création du pointeur intelligent à partir d'un pointeur normal.&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; MyObject&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #666666;&quot;&gt;// Utilisation du pointeur intelligent comme un pointeur normal.&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    ptr&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setMembre&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;maValeur&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #666666;&quot;&gt;// Appel d'une méthode utilisant ce pointeur&lt;/span&gt;
  maMethode&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Lorsque l'on quitte le bloc, si le comptage de référence tombe à 0, on supprime le pointeur. A l'intérieur de &lt;code&gt;maMethode()&lt;/code&gt; le nombre de référence sera passé à 2. Si la méthode utilise le pointeur mais ne l'assigne nul part, le nombre de référence devrait être retombé à 1 et donc ici sera décrémenté à 0.&lt;/p&gt;


&lt;p&gt;Si par contre, &lt;code&gt;maMethode()&lt;/code&gt; fait des opérations d'assignation de &lt;code&gt;ptr&lt;/code&gt; et conserve une copie, le comptage ne tombera pas à 0 tant que l'objet restera utilisé (assigné) ailleurs.&lt;/p&gt;


&lt;p&gt;Regardons un exemple de &lt;code&gt;maMethode()&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; maMethode&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  ptr&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setMembre2&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;maValeur&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Au début du bloc, ici le comptage de référence est à 2 et sera décrémenté à la sortie de la méthode. On peut modifier les membres de &lt;code&gt;ptr&lt;/code&gt;, et dans ce cas pas de changement du comptage de référence.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;this&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;monPtr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Au contraire, on peut également l'assigner à un autre objet. Dans ce cas le comptage de référence de cet objet passera à 3. A la sortie de la méthode il sera décrémenté et passera alors à 2. L'objet ne sera pas supprimé tant qu'on ne fera pas un &lt;code&gt;this-&amp;gt;monPtr.clear()&lt;/code&gt; ou que &lt;code&gt;this&lt;/code&gt; ne sera pas détruit.&lt;/p&gt;


&lt;p&gt;Si on veut garder une référence d'un pointeur mais qu'on ne souhaite pas que celle-ci incrémente le nombre de référence du &lt;code&gt;QSharedPointer&lt;/code&gt;, il est possible de créer un pointeur &lt;em&gt;faible&lt;/em&gt;. Ce pointeur passe par l'objet &lt;code&gt;QWeakPointer&lt;/code&gt;. Pour obtenir ce type de pointeur, il suffit de faire&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptrW &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptr&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;toWeakRef &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&lt;code&gt;ptrW&lt;/code&gt; n'incrémente donc pas le comptage de référence, cela signifie donc que le pointeur peut être détruit même si un objet &lt;code&gt;QWeakPointer&lt;/code&gt; existe. Il sera alors possible de faire un &lt;code&gt;ptrW.isNull()&lt;/code&gt; pour savoir si le pointeur est toujours valide. Si l'utilisateur a également besoin d'avoir accès à un membre de l'objet, il pourra le transformer en &lt;code&gt;QSharedPointer&lt;/code&gt; avant de l'utiliser sauf si le pointeur est &lt;code&gt;null&lt;/code&gt;.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr2 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptrW&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;toStrongRef &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; 
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
   ptr&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;maMethodePtr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il faut tester que &lt;code&gt;ptr2&lt;/code&gt; est encore valide, car tant que la transformation du pointeur &lt;em&gt;faible&lt;/em&gt; vers le &lt;code&gt;QSharedPointer&lt;/code&gt; n'a pas encore été fait, il est possible que le nombre de référence vers l'objet soit tombé à 0 et qu'il ait été supprimé.&lt;/p&gt;


&lt;p&gt;&lt;a name=&quot;comment_utiliser_this&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Comment utiliser &lt;code&gt;this&lt;/code&gt;&lt;/h4&gt;


&lt;p&gt;Un des points peu pratique de l'utilisation de &lt;code&gt;QSharedPointer&lt;/code&gt; est que le comptage de référence ne fonctionne pas si plusieurs &lt;code&gt;QSharedPointer&lt;/code&gt; pointent vers le même objet mais ont tous été créés à partir du pointeur C. Prenons par exemple, le cas suivant&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;MyObject &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; MyObject&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr1 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr2 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le problème d'écrire ces lignes ainsi, et que pour  &lt;code&gt;ptr1&lt;/code&gt; comme pour &lt;code&gt;ptr2&lt;/code&gt;, l'objet n'est référencé qu'une fois. Ainsi le premier qui tombera à 0 détruira l'objet, alors que l'autre pourrait encore l'utiliser. Il faut donc écrire les choses comme suite&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qsharedpointer/QSharedPointer2.png&quot; alt=&quot;QSharedPointer2.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;QSharedPointer2.png, janv. 2011&quot; /&gt;&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr1 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; MyObject&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr2 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptr1&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ainsi &lt;code&gt;ptr1&lt;/code&gt; et &lt;code&gt;ptr2&lt;/code&gt; ont bien chacun connaissance de l'existence de l'autre. Cela contraint donc à remplacer toutes les déclarations du type &lt;code&gt;MyObject*&lt;/code&gt; par &lt;code&gt;QSharedPointer&amp;lt;MyObject&amp;gt;&lt;/code&gt;. Ceci est donc à faire dans les paramètres des méthodes, dans les membres, dans la déclaration des variables locales, ... . On ne peut donc plus utiliser le pointeur C &lt;code&gt;MyObject*&lt;/code&gt; directement, mais seulement au travers de &lt;code&gt;QSharedPointer&lt;/code&gt; ou de &lt;code&gt;QWeakPointer&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Cela commence à poser problème lors de l'utilisation de &lt;code&gt;this&lt;/code&gt; dans un objet. Imaginons une méthode d'un objet mettant à jour des membres fils avec en paramètre le père. Nous aurions alors tendance à écrire ceci&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; Object2&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;setParent&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; parent&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
...
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
....
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; MyObject&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;setMember&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;Object2 &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  _membre &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; obj&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    obj&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setParent&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ceci ne marchera pas car on créerait un nouvel objet &lt;code&gt;QSharedPointer&lt;/code&gt; commençant son comptage de référence à 1, alors que nous en avons déjà au moins un autre pointant vers notre instance&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-2&quot; id=&quot;rev-pnote-628-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;. &lt;code&gt;MyObject&lt;/code&gt; pourrait alors être détruit alors qu'il est encore utilisé par &lt;code&gt;Object2&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Pour éviter cela, il faut alors passer par un pointeur &lt;em&gt;intelligent&lt;/em&gt; &lt;code&gt;this&lt;/code&gt;. Pour cela nous allons utiliser deux choses&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Un membre nommé &lt;code&gt;_this&lt;/code&gt; de type pointeur &lt;em&gt;intelligent&lt;/em&gt; &lt;code&gt;QWeakPointer&lt;/code&gt;, contenant une référence à l'objet lui même. (Nous n'utilisons pas un QSharedPointer, pour éviter une référence circulaire, voir le paragraphe suivant).&lt;/li&gt;
&lt;li&gt;Une méthode statique utilisée pour la création (nous n'allons plus utiliser le constructeur, car à ce moment, il n'existe pas encore de QSharedPointer pointant vers notre objet).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Voici un exemple de comment écrire le constructeur maison&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; MyObject
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; create&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QString parametre&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; MyObject&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;parametre&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    ptr&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;_this &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptr.&lt;span style=&quot;color: #007788;&quot;&gt;toWeakRef&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  MyObject&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QString parametre&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    ...
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; _this&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le constructeur devient alors privé (ou protégé si on a besoin de la notion d'héritage) afin d'obliger l'utilisateur de la classe à utiliser notre méthode de création. Dans notre nouvelle méthode de création &lt;code&gt;create&lt;/code&gt;, qui est une méthode statique, nous allons créer le pointeur et initialiser le &lt;code&gt;QWeakPointer&lt;/code&gt; de notre objet avec le pointeur &lt;em&gt;intelligent&lt;/em&gt; que nous venons de créer. Nous retournons un &lt;code&gt;QSharedPointer&lt;/code&gt;. La méthode &lt;code&gt;create&lt;/code&gt; devient alors notre nouveau constructeur, mais créant des instances d'objets de type &lt;code&gt;QSharedPointer&amp;lt;MyObject&amp;gt;&lt;/code&gt; et non plus des instances d'objet &lt;code&gt;MyObject*&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Notre méthode &lt;code&gt;setMember()&lt;/code&gt; peut alors être ré-écrite&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; MyObject&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;setMember&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;Object2 &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  _membre &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; obj&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    obj&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setParent&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;_this.&lt;span style=&quot;color: #007788;&quot;&gt;toStrongRef&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a name=&quot;comment_eviter_les_references_circulaires&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Comment éviter les références circulaires&lt;/h4&gt;


&lt;p&gt;Le principe d'une référence circulaire est qu'un objet A référence l'objet B et l'objet B référence l'objet A.&lt;/p&gt;


&lt;p&gt;Voici par exemple, un cas de référence circulaire&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; A
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; create&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; A&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  ~A&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  A&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    b &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; B&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    b&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setA&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;_this&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;B&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; b&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; _this&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; B
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;B&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; create&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; 
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;B&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; B&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; setA&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; b&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; getA&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;  a&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cela peut-être aussi le cas, si par exemple une instance d'objet C référence des instances d'objets fils C, qui possèdent eux-même un pointeur vers l'objet C père.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; C
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; create&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; C&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    _this &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptr.&lt;span style=&quot;color: #007788;&quot;&gt;toWeakPtr&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  ~C&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; addChild&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; c&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    _childs.&lt;span style=&quot;color: #007788;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;c&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    c&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setParent&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;_this&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; setParent&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; c&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; getParent&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  C&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; _this&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; _parent&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  QList&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;C&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; _childs&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Dans ces cas là, on a&amp;nbsp;:
- L'objet A possède la référence vers l'objet B
- L'objet B possède une référence vers l'objet A.
- Même principe avec l'objet C&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qsharedpointer/QSharedPointer3.png&quot; alt=&quot;QSharedPointer3.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;QSharedPointer3.png, janv. 2011&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Dans ce cas, il restera alors toujours une référence vers A, et une vers B, même si plus aucune variable ne référence ces objets. Cette référence circulaire fait que l'objet ne sera jamais détruit même si on n'a plus besoin de l'objet.&lt;/p&gt;


&lt;p&gt;Si on décide que l'objet A sera l'objet maitre (donc que sa destruction engendrera la destruction de l'objet B), on peut alors écrire les choses ainsi pour l'objet B&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; B
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;B&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; create&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; 
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;B&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; B&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; setA&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; b&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; getA&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
  QWeakPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;A&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;  a&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Dans ce cas, avec l'utilisation d'un &lt;code&gt;QWeakPointer&lt;/code&gt;, lorsque qu'il n'existera plus de référence vers l'objet A, le pointeur &lt;em&gt;faible&lt;/em&gt; &lt;code&gt;a&lt;/code&gt; sera mis à jour comme ne contenant plus de référence&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-3&quot; id=&quot;rev-pnote-628-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt;. L'instance de l'objet A sera réellement détruite. Il n'y aura alors plus aucune référence vers l'objet B qui sera alors également détruit&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-4&quot; id=&quot;rev-pnote-628-4&quot;&gt;4&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;&lt;a name=&quot;utilisation_dans_les_applications_multi_thread&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Utilisation dans les applications multi-thread.&lt;/h4&gt;


&lt;p&gt;L'utilisation de &lt;code&gt;QSharedPointer&lt;/code&gt; simplifie l'écriture des applications multi-thread (les objets &lt;code&gt;QSharedPointer&lt;/code&gt; et &lt;code&gt;QWeakPointer&lt;/code&gt; sont thread-safe).&lt;/p&gt;


&lt;p&gt;Dans ces applications il n'y a alors plus besoin de se soucier si l'objet est en cours d'utilisation ailleurs dans l'application avant de le supprimer&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-5&quot; id=&quot;rev-pnote-628-5&quot;&gt;5&lt;/a&gt;]&lt;/sup&gt;. Lorsqu'un pointeur ne devient plus utilisé dans un thread donné, il ne sera détruit que s'il n'y a pas d'autres références dans d'autres threads de l'application&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-6&quot; id=&quot;rev-pnote-628-6&quot;&gt;6&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Avec l'utilisation de &lt;code&gt;QWeakPointer&lt;/code&gt;, un thread pourra tester l'existence du pointeur avant d'effectuer une opération et pourra aviser le cas échéant sans faire planter toute l'application&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-7&quot; id=&quot;rev-pnote-628-7&quot;&gt;7&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;&lt;a name=&quot;utilisation_d_un_pool&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Utilisation d'un pool&lt;/h4&gt;


&lt;p&gt;Si la création et la destruction d'un objet est coûteux, il est envisageable de diminuer le coût de destruction et de création d'un thread en utilisant un Pool d'objet. Dans ce cas l'objet &lt;a href=&quot;http://doc.qt.nokia.com/4.6/qqueue.html&quot; hreflang=&quot;en&quot; title=&quot;Documentation de QQueue&quot;&gt;QQueue&lt;/a&gt; pourra être utilisé pour représenter notre Pool.&lt;/p&gt;


&lt;p&gt;Lors de la demande de création, en utilisant notre méthode &lt;code&gt;create&lt;/code&gt; ci-dessus, on prend alors une valeur du pool (si disponible) et on la retourne sous forme d'un &lt;code&gt;QSharedPointer&lt;/code&gt;.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; MyObject&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;create&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  MyObject &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; c_ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;_queue.&lt;span style=&quot;color: #007788;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
	c_ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; _queue.&lt;span style=&quot;color: #007788;&quot;&gt;dequeue&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;else&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt; 
	c_ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; MyObject&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;MyObject&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;c_ptr, ReturnToPool&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  ptr&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;_this &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; ptr.&lt;span style=&quot;color: #007788;&quot;&gt;toWeakRef&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Dans l'exemple ci-dessus&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-8&quot; id=&quot;rev-pnote-628-8&quot;&gt;8&lt;/a&gt;]&lt;/sup&gt;, on demande à la queue, qui doit être une variable globale ou statique, un élément, et si ce n'est pas possible, on crée un nouvel objet de type &lt;code&gt;MyObject&lt;/code&gt; (dont on suppose la création coûteuse).&lt;/p&gt;


&lt;p&gt;Lors de la création du &lt;code&gt;QSharedPointer&lt;/code&gt; on utilise alors le constructeur &lt;code&gt;QSharedPointer ( T * ptr, Deleter deleter )&lt;/code&gt; sur lequel on définit une méthode &lt;code&gt;Deleter&lt;/code&gt; nommée &lt;code&gt;ReturnToPool&lt;/code&gt; dont le but est de remettre les objets en pool.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; ReturnToPool&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;MyObject &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;_queue.&lt;span style=&quot;color: #007788;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt; MAX_SIZE_QUEUE&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
	_queue.&lt;span style=&quot;color: #007788;&quot;&gt;enqueue&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
  &lt;span style=&quot;color: #0000ff;&quot;&gt;else&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #0000dd;&quot;&gt;delete&lt;/span&gt; obj&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
  &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Dans ce cas de retour au pool, si le pool est rempli, on détruit l'objet (pour éviter de consommer trop de mémoire), sinon on l'ajoute au pool. Dans ce cas, le pool est agrandi au fur et à mesure des besoins, jusqu'à une taille limite.&lt;/p&gt;


&lt;p&gt;Bien sûr il faut que la performance de l'utilisation d'un pool soit plus intéressante que celle de la création de l'objet et de son initialisation.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;&lt;ins&gt;Attention&lt;/ins&gt;&amp;nbsp;: Ce point ne fonctionne, par contre, pas si l'objet (&lt;code&gt;MyObject&lt;/code&gt;) est un descendant de &lt;code&gt;QObject&lt;/code&gt;. En effet &lt;code&gt;QObject&lt;/code&gt; garde une référence du &lt;code&gt;QSharedPointer&lt;/code&gt; en mémoire et lors de la réutilisation du &lt;code&gt;QObject&lt;/code&gt; une erreur indique que l'objet n'a pas été détruit et est déjà utilisé par un &lt;code&gt;QSharedPointer&lt;/code&gt;. On n'a pas le problème avec &lt;code&gt;std::tr1::shared_ptr&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;&lt;a name=&quot;benchmark&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Benchmark&lt;/h3&gt;


&lt;p&gt;Le but du benchmark est de se faire une idée sur les performances d'une application utilisant des &lt;code&gt;QSharedPointer&lt;/code&gt; à la place des pointeurs normaux. Attention, ce bench ne prend pas en compte le besoin potentiel de Mutex, de comptage de référence manuel, ... dans les applications multi-thread qui pourrait être nécessaire pour ne pas supprimer le pointeur si besoin.&lt;/p&gt;


&lt;p&gt;Dans ce test nous allons tester également (en comparaison), le pointeur &lt;em&gt;intelligent&lt;/em&gt; du C++0x&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#pnote-628-9&quot; id=&quot;rev-pnote-628-9&quot;&gt;9&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Nous allons donc tester les opérations courantes de création, destruction, modification, affectation.&lt;/p&gt;


&lt;p&gt;&lt;a name=&quot;code_source&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Code source&lt;/h4&gt;


&lt;p&gt;Le code source est disponible, attaché au billet. Dans la suite du billet, seuls les morceaux intéressants du benchmark seront décris. Le benchmark utilise QTest. Nous avons créé un objet bidon &lt;code&gt;ObjetTest&lt;/code&gt; qui dans le constructeur allouera un pointeur et remplira une liste, et le destructeur supprime ce pointeur (et forcément la liste).&lt;/p&gt;


&lt;p&gt;Pour que chaque test soit indépendant, le jeu de test sera initialisé avant le début de chaque QBENCHMARK et détruit à la fin du bloc. Nous aurons quatre méthodes&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Allocation&lt;/li&gt;
&lt;li&gt;Modification&lt;/li&gt;
&lt;li&gt;Affectation&lt;/li&gt;
&lt;li&gt;Nettoyage&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour chaque test nous allons faire le test avec&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;un pointeur C standard&lt;/li&gt;
&lt;li&gt;le pointeur &lt;code&gt;QSharedPointer&lt;/code&gt; de &lt;em&gt;Qt&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;le pointeur &lt;code&gt;std::tr1::shared_ptr&lt;/code&gt; de &lt;em&gt;C++0x&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour le test d'allocation et le test de nettoyage, nous allons également utiliser l'optimisation possible, vu ci-dessus, d'un Pool d'objet. Nous allons faire le test avec&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le pointeur &lt;code&gt;QSharedPointer&lt;/code&gt; de &lt;em&gt;Qt&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;le pointeur &lt;code&gt;std::tr1::shared_ptr&lt;/code&gt; de &lt;em&gt;C++0x&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a name=&quot;le_jeu_de_test&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;Le jeu de test&lt;/h4&gt;


&lt;p&gt;&lt;a name=&quot;test_de_l_allocation&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;Test de l'allocation&lt;/h5&gt;


&lt;p&gt;La création du pointeur en utilisant &lt;code&gt;QSharedPointer&lt;/code&gt; instancie le pointeur ainsi que le &lt;code&gt;QSharedPointer&lt;/code&gt;. Le temps d'exécution est donc potentiellement deux fois plus long (voir le benchmark à la fin de ce billet).&lt;/p&gt;


&lt;p&gt;Pour la création du pool, nous allons utiliser une méthode qui créera le pointeur s'il n'est pas dans le pool, et sinon prendra le pointeur du pool. Dans notre cas de test, il y aura toujours une valeur dans le pool, que l'on aura rempli au préalable.&lt;/p&gt;


&lt;p&gt;La méthode &lt;code&gt;createFromPool()&lt;/code&gt; et &lt;code&gt;createFromBoostPool()&lt;/code&gt; est sensiblement identique&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; createFromPool&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
        ObjetTest &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; c_ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;_queue.&lt;span style=&quot;color: #007788;&quot;&gt;size&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
          c_ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; _queue.&lt;span style=&quot;color: #007788;&quot;&gt;dequeue&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;else&lt;/span&gt;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
          c_ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; ObjetTest&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;c_ptr, returnToPool&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; ptr&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;C Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;ObjetTest&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; ObjetTest&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Qt Smart Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; ObjetTest&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Qt Smart Pointer as Pool&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; createFromPool &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;C++0x Smart Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;tr1&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;shared_ptr&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; ObjetTest&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;C++0x Smart Pointer as Pool&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;tr1&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;shared_ptr&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; ptr &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; createFromBoostPool &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;&lt;a name=&quot;test_de_modification_d_une_donnee&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;Test de Modification d'une donnée&lt;/h5&gt;


&lt;p&gt;Pour la modification d'une donnée, on génère un nombre aléatoire que l'on va stocker (toujours le même pour chaque test, cela n'a pas d'importance). La génération du nombre aléatoire se fait en dehors du bloc, pour éviter de polluer le test avec le calcul d'un nombre aléatoire. Ici il n'y a pas création d'affectation du pointeur, juste une affectation d'une valeur dans le contenu du pointeur. La syntaxe pour le C, et pour le pointeur intelligent est identique.&lt;/p&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;C Pointer / Qt Smart Pointer / C++0x Smart Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;obj&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;value &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; random_number&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;&lt;a name=&quot;test_d_affectation&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;Test d'affectation&lt;/h5&gt;


&lt;p&gt;Pour l'affectation nous allons créer une nouvelle variable qui pointera sur le même pointeur, et sur lequel on fera une modification. La création d'un pointeur peut arriver par exemple lors du passage du pointeur à une fonction, ou lors de la déclaration d'une variable devant contenir la même valeur. Cette déclaration supplémentaire a peu d'impact pour un pointeur C mais pour un pointeur &lt;em&gt;intelligent&lt;/em&gt; oblige la création d'un objet, et l'incrément d'un nombre d'instance (qu'on décrémente ici dans la même boucle).&lt;/p&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;C Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;ObjetTest &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; obj2 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; obj&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
obj2&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;value &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; random_number&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Qt Smart Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;QSharedPointer&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; obj2 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; obj&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
obj2&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;value &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; random_number&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;C++0x Smart Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;tr1&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;shared_ptr&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;ObjetTest&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt; obj2 &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; obj&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
obj2&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;value &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; random_number&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;&lt;a name=&quot;test_de_destruction&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;Test de destruction&lt;/h5&gt;


&lt;p&gt;Pour ce test, nous allons initialiser une liste de pointeur, et pour le benchmark, nous allons supprimer un à un chaque élément de la liste.
La destruction du pointeur en C se fait par un &lt;code&gt;delete&lt;/code&gt;. Pour le pointeur ''intelligent', il n'y a pas de destruction explicite. Nous allons juste supprimer le pointeur de la liste, le pointeur sera alors automatiquement détruit car il n'y aura plus de référence vers ce pointeur.&lt;/p&gt;


&lt;p&gt;Pour le cas de test utilisant la notion du Pool, on aura créé le pointeur avec le delete &lt;code&gt;returnToPool()&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; returnToPool&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;ObjetTest &lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
        _queue.&lt;span style=&quot;color: #007788;&quot;&gt;enqueue&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;obj&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cette méthode ne fait pas de réelle destruction, mais juste un ajout de l'objet au pool.&lt;/p&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;C Pointer&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;delete&lt;/span&gt; c_ptr_list.&lt;span style=&quot;color: #007788;&quot;&gt;at&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
c_ptr_list.&lt;span style=&quot;color: #007788;&quot;&gt;removeFirst&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Qt Smart Pointer / Qt Smart Pointer as Pool / C++0x Smart Pointer / C++0x Smart Pointer as Pool &lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;smart_ptr_list.&lt;span style=&quot;color: #007788;&quot;&gt;removeFirst&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;&lt;a name=&quot;resultat_du_test&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;Résultat du test&lt;/h5&gt;


&lt;p&gt;Le test a été fait en utilisant la version 4.6.3 de Qt. Test effectué pour 5 000 000 itérations.&lt;/p&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th/&gt;&lt;th&gt;Pointeur C&lt;/th&gt;&lt;th&gt;Pointeur Qt&lt;/th&gt;&lt;th&gt;Pointeur C++0x&lt;/th&gt;&lt;th&gt;Pool en utilisant QSharedPointer&lt;/th&gt;&lt;th&gt;Pool en utilisant std::tr1::shared_ptr&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Allocation&lt;/th&gt;&lt;td&gt;0.0004275 msec&lt;/td&gt;&lt;td&gt;0.0007692 msec&lt;/td&gt;&lt;td&gt;0.0006604 msec&lt;/td&gt;&lt;td&gt;0.0002590 msec&lt;/td&gt;&lt;td&gt;0.0002286 msec&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Modification&lt;/th&gt;&lt;td&gt;0.000010 msec&lt;/td&gt;&lt;td&gt;0.000012 msec&lt;/td&gt;&lt;td&gt;0.000012 msec&lt;/td&gt;&lt;td colspan=&quot;2&quot; rowspan=&quot;2&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Affectation&lt;/th&gt;&lt;td&gt;0.000010 msec&lt;/td&gt;&lt;td&gt;0.0000386 msec&lt;/td&gt;&lt;td&gt;0.0000230 msec&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Destruction&lt;/th&gt;&lt;td&gt;0.000190 msec&lt;/td&gt;&lt;td&gt;0.0003161 msec&lt;/td&gt;&lt;td&gt;0.0003359 msec&lt;/td&gt;&lt;td&gt;0.0004003 msec&lt;/td&gt;&lt;td&gt;0.0003601 msec&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;Conclusion que l'on peut en tirer, le pointeur C est ce qu'il y a de plus rapide à partir du moment où on fait de l'allocation de l'affectation ou de la destruction. Par contre il n'apporte pas la souplesse qu'apporte les pointeurs &lt;em&gt;intelligents&lt;/em&gt; entre autre pour les applications multi-threadé.&lt;/p&gt;


&lt;p&gt;On remarque que le pointeur C++0x est plus rapide pour la création, mais apparemment plus lent en destruction. Il est également possible avec le pool de gagner en performance (surtout en création). Par contre le coût de destruction de l'objet n'est pas encore assez fort pour y gagner en utilisant le pool.&lt;/p&gt;


&lt;p&gt;Ensuite il est important de se faire son propre jugement selon ses besoins. Si besoin le source est attaché, vous pouvez faire vos propres tests.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-1&quot; id=&quot;pnote-628-1&quot;&gt;1&lt;/a&gt;] Si à un moment donné il faut utiliser le pointeur C pour une raison quelconque, on peut utiliser &lt;code&gt;ptr.data()&lt;/code&gt; mais il faut s'assurer que le pointeur ne sera pas détruit en déclarant un &lt;code&gt;QSharedPointer&lt;/code&gt; dans le même bloc utilisant le pointeur C. Le &lt;code&gt;QSharedPointer&lt;/code&gt; ne devra être détruit qu'après utilisation du pointeur C. Ceci peut être fait dans certain cas pour des raisons de performance.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-2&quot; id=&quot;pnote-628-2&quot;&gt;2&lt;/a&gt;] Sinon nous ne serions plus là pour lancer la méthode&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-3&quot; id=&quot;pnote-628-3&quot;&gt;3&lt;/a&gt;] Le &lt;code&gt;QWeakPointeur&lt;/code&gt; ne gardant pas d'instance d'objet, car il n'incrémente pas le compteur de référence&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-4&quot; id=&quot;pnote-628-4&quot;&gt;4&lt;/a&gt;] s'il n'existe pas de référence vers l'objet B ailleurs dans l'application&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-5&quot; id=&quot;pnote-628-5&quot;&gt;5&lt;/a&gt;] Attention quand même, &lt;code&gt;QSharedPointer&lt;/code&gt; protège le pointeur mais pas le contenu&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-6&quot; id=&quot;pnote-628-6&quot;&gt;6&lt;/a&gt;] d'autres threads pouvant inclure le thread principal&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-7&quot; id=&quot;pnote-628-7&quot;&gt;7&lt;/a&gt;] Si l'objet est supprimé, &lt;code&gt;QWeakPointer&lt;/code&gt;, sera alors remis à &lt;code&gt;null&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-8&quot; id=&quot;pnote-628-8&quot;&gt;8&lt;/a&gt;] Dans le code en question, il faudrait ajouter la notion de mutex autour de la gestion de la queue, en cas de création parallèle.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#rev-pnote-628-9&quot; id=&quot;pnote-628-9&quot;&gt;9&lt;/a&gt;] Le pointeur &lt;em&gt;intelligent&lt;/em&gt; &lt;code&gt;shared_ptr&lt;/code&gt; de C++0x à pour origine le pointeur Boost&lt;/p&gt;&lt;/div&gt;
</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/qsharedpointer/smart_benchmark.7z"
      length="1805" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2011/01/17/Performance-de-l-utilisation-de-QSharedPointer#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/628</wfw:commentRss>
      </item>
    
  <item>
    <title>[C++/Qt] Concaténation de chaînes de caractères</title>
    <link>http://www.shadoware.org/post/2010/12/21/%5BC/Qt%5D-Concat%C3%A9nation-de-chaine-de-caract%C3%A8re</link>
    <guid isPermaLink="false">urn:md5:5f35cced448e3f18b1997d657393c995</guid>
    <pubDate>Wed, 22 Dec 2010 13:03:00 +0100</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Performances</category>
        <category>libre</category><category>nokia</category><category>performance</category><category>planet</category><category>qstring</category><category>qt</category><category>trolltech</category>    
    <description>&lt;h3&gt;Présentation&lt;/h3&gt;


&lt;p&gt;Qt est un framework orienté objet écrit en C++ et permettant de faire des interfaces graphiques à l’aide de ces widgets. Ce framework est utilisé par le projet KDE depuis ses débuts pour en faire un environnement très complet.&lt;/p&gt;


&lt;p&gt;Qt permet donc de faire des interfaces graphiques mais aussi d’accéder à des bases de données SQL, de faire de la communication réseau, une gestion simplifiée des threads, la lecture de fichier XML. Qt intègre aussi le moteur HTML Webkit.&lt;/p&gt;


&lt;p&gt;Qt ajoute une couche supplémentaire au C++ permettant de faire de l’introspection de classe un peu plus poussée (comme l’appel d’une méthode dont on ne connaît le nom qu’à l’exécution). Qt permet également la gestion d’évènement par l’intermédiaire d’un système puissant de SIGNALS et de SLOTS.&lt;/p&gt;


&lt;p&gt;Dans la suite de cet article nous allons nous concentrer sur une très petite partie de Qt mais qui est utilisée dans beaucoup d’applications écrites en Qt&amp;nbsp;: les chaînes de caractères, et plus précisément, la concaténation de chaînes de caractères.&lt;/p&gt;    &lt;h2&gt;Concaténation de chaînes de caractères.&lt;/h2&gt;


&lt;p&gt;Comme dans d’autres langages, la concaténation de chaînes de caractères se fait à l'aide de l'opérateur &lt;code&gt;+&lt;/code&gt;. Prenons un exemple simple&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;QString&amp;gt;&lt;/span&gt;
&amp;nbsp;
QString abc &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;abc&amp;quot;&lt;/span&gt;, def &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;def&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
QString result&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
result &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; abc &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; def&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;



&lt;p&gt;L'utilisation de l'opérateur &lt;code&gt;+&lt;/code&gt; facilite l'écriture de la concaténation des chaînes de caractères (tout comme l'opérateur &lt;code&gt;==&lt;/code&gt; permet de facilement comparer des chaînes de caractères de type QString).&lt;/p&gt;


&lt;p&gt;Malheureusement cette écriture rend le code peu performant pour diverses raisons (que l’on peut retrouver dans la documentation de l’objet QString).&lt;/p&gt;


&lt;h3&gt;Concaténation rapide de chaînes de caractères&lt;/h3&gt;


&lt;p&gt;A partir de Qt 4.6, Nokia, a ajouté un &lt;code&gt;template&lt;/code&gt; nommé QStringBuilder (cet objet fait beaucoup penser à l'objet StringBuilder de JAVA permettant d'accélérer les concaténations de chaînes de caractères).&lt;/p&gt;


&lt;p&gt;Ce template ne s’utilise pas directement mais au travers de l'opérateur &lt;code&gt;%&lt;/code&gt;. En remplaçant donc l'opérateur &lt;code&gt;+&lt;/code&gt; par &lt;code&gt;%&lt;/code&gt; on gagne en performance (dixit la doc de Qt).&lt;/p&gt;


&lt;p&gt;Pour pouvoir utiliser l'opérateur, il suffit d'inclure le fichier &lt;code&gt;QStringBuilder&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;QStringBuilder&amp;gt;&lt;/span&gt;
&amp;nbsp;
QString abc &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;abc&amp;quot;&lt;/span&gt;, def &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;def&amp;quot;&lt;/span&gt;, ghi &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;ghi&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
QString result&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
result &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; abc &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; def &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; ghi&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Une autre possibilité est de définir (par exemple dans votre fichier .pro ou dans un include général de votre application)  les définitions &lt;code&gt;QT_USE_FAST_CONCATENATION&lt;/code&gt;,  et &lt;code&gt;QT_USE_FAST_OPERATOR_PLUS&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Ces définitions permettent de remplacer l'opérateur &lt;code&gt;+&lt;/code&gt; par l'opérateur &lt;code&gt;%&lt;/code&gt; dans toute l'application. Par contre cette opération peut demander quelques modifications de votre code.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#define QT_USE_FAST_CONCATENATION&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#define QT_USE_FAST_OPERATOR_PLUS&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;QString&amp;gt;&lt;/span&gt;
&amp;nbsp;
QString abc &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;abc&amp;quot;&lt;/span&gt;, def &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;def&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
QString result&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
result &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; abc &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; def&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;Benchmark&lt;/h3&gt;


&lt;p&gt;Nous allons donc dans la suite du document vérifier que l'opérateur &lt;code&gt;%&lt;/code&gt; est plus rapide que l'opérateur &lt;code&gt;+&lt;/code&gt;. Pour cela nous allons utiliser le module de benchmark de Qt.&lt;/p&gt;


&lt;h4&gt;Code source&lt;/h4&gt;


&lt;p&gt;Voici le petit programme permettant de tester la performance de la concaténation. Notre exemple simple va constituer à la concaténation de 26 chaînes de caractères créées au début. L'appel se fera une première fois en utilisant l'opérateur &lt;code&gt;+&lt;/code&gt; et une seconde fois en utilisant l'opérateur &lt;code&gt;%&lt;/code&gt;.&lt;/p&gt;

&lt;pre class=&quot;cpp cpp&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;QtCore/QString&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;QtTest/QtTest&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;QStringBuilder&amp;gt;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; TestPerf &lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; QObject
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    Q_OBJECT
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
    TestPerf&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt; Q_SLOTS&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; concat&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; concat_data&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
TestPerf&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;TestPerf&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; TestPerf&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;concat&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
	QFETCH&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt;, useStringBuilder&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
	QString result&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	QString a&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;a&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, b&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;b&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, c&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;c&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, d&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;d&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, e&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;e&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, f&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;f&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, g&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;g&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, h&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;h&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, i&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;i&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, j&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;j&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, k&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;k&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, l&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;l&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, m&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;m&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, n&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;n&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, o&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;o&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, p&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;p&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, q&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;q&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, r&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;r&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, s&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;s&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, t&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;t&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, u&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;u&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, v&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;v&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, w&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;w&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, x&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;x&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, y&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;y&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, z&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;z&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;useStringBuilder&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
		QBENCHMARK
		&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #666666;&quot;&gt;// Concaténation en utilisant QStringBuilder&lt;/span&gt;
			&lt;span style=&quot;color: #666666;&quot;&gt;// Dans ce cas la concaténation devrait être plus rapide&lt;/span&gt;
			result &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; a &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; b &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; c &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; d &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; e &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; f &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; g &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; h &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; i &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; j &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; k &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; l &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; m &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; n &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; o &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; p &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; q &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; r &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; s &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; t &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; u &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; v &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; w &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; x &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; y &lt;span style=&quot;color: #000040;&quot;&gt;%&lt;/span&gt; z&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;else&lt;/span&gt;
	&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
		QBENCHMARK
		&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
			&lt;span style=&quot;color: #666666;&quot;&gt;// Concaténation en n'utilisant pas QStringBuilder. On utilise alors la concaténation normal de chaînes de caractères en utilisant&lt;/span&gt;
			&lt;span style=&quot;color: #666666;&quot;&gt;// QString&lt;/span&gt;
			result &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; a &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; b &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; c &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; d &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; e &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; f &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; g &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; h &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; i &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; j &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; k &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; l &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; m &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; n &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; o &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; p &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; q &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; r &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; s &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; t &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; u &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; v &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; w &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; x &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; y &lt;span style=&quot;color: #000040;&quot;&gt;+&lt;/span&gt; z&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
	&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; TestPerf&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;concat_data&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
	QTest&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;addColumn&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;useStringBuilder&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
	QTest&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;newRow&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;Don't use QStringBuilder&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
	QTest&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #007788;&quot;&gt;newRow&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;Use QStringBuilder&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
QTEST_APPLESS_MAIN&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;TestPerf&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;quot;tst_testperf.moc&amp;quot;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Résultat du test&lt;/h4&gt;


&lt;p&gt;Le test a été fait en utilisant la version 4.6.3 de Qt. Le résultat est sensiblement le même avec la version 4.7.0&lt;/p&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Sans QStringBuilder&lt;/th&gt;&lt;td&gt;0.00367 msec&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th&gt;Avec QStringBuilder&lt;/th&gt;&lt;td&gt;0.00046 msec&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;On voit dans ce test que la version en utilisant QStringBuilder est 8 fois plus rapide que sans. Bien sûr vu le temps que prend la concaténation de chaînes de caractères, ce test commence à avoir de l'intérêt uniquement à partir du moment où on fait beaucoup de concaténation dans la seconde, ou si les temps de réponses sont critiques.&lt;/p&gt;


&lt;p&gt;Sur ce, je vous souhaite à tous un Joyeux noël et une bonne année.&lt;/p&gt;</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/concat/test-perfconcat.7z"
      length="862" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2010/12/21/%5BC/Qt%5D-Concat%C3%A9nation-de-chaine-de-caract%C3%A8re#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2010/12/21/%5BC/Qt%5D-Concat%C3%A9nation-de-chaine-de-caract%C3%A8re#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/626</wfw:commentRss>
      </item>
    
  <item>
    <title>Calcul de la distance entre deux fichiers</title>
    <link>http://www.shadoware.org/post/2010/06/06/Calcul-de-la-Distance</link>
    <guid isPermaLink="false">urn:md5:a8e01d8f9c4c3ba53558afe790f6d995</guid>
    <pubDate>Sun, 06 Jun 2010 11:40:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>C++</category>
        <category>cartographie</category><category>compression</category><category>distance</category><category>libre</category><category>planet</category><category>qt</category>    
    <description>&lt;h3&gt;Présentation&lt;/h3&gt;


&lt;p&gt;Suite à un &lt;a href=&quot;http://linuxfr.org/forums/20/28366.html&quot; hreflang=&quot;fr&quot;&gt;billet sur LinuxFR&lt;/a&gt;, où je demandais comment calculer la distance (ou le pourcentage de similitude entre deux logiciels), j'ai obtenu la formule suivante&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
distance = 1 - ( C(A) + C(B) - C(AB) ) / Max(C(A), C(B))
&lt;/pre&gt;


&lt;p&gt;où C(X) est la taille du fichier X compressé&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2010/06/06/Calcul-de-la-Distance#pnote-625-1&quot; id=&quot;rev-pnote-625-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Après avoir testé les formats &lt;code&gt;gzip&lt;/code&gt;, &lt;code&gt;bzip2&lt;/code&gt; et &lt;code&gt;lzma&lt;/code&gt;, j'ai conclu que le format de compression le plus performant pour le calcul, est le format &lt;code&gt;lzma&lt;/code&gt;, car le dictionnaire avec &lt;em&gt;la mise en commun&lt;/em&gt; était le plus gros, et donc le calcul de distance est plus efficace.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2010/06/06/Calcul-de-la-Distance#rev-pnote-625-1&quot; id=&quot;pnote-625-1&quot;&gt;1&lt;/a&gt;] On peut retrouver l'explication de cette formule &lt;a href=&quot;http://interstices.info/jcms/c_21828/classer-musiques-langues-images-textes-et-genomes&quot; hreflang=&quot;fr&quot;&gt;ici&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
    &lt;h3&gt;Le programme&lt;/h3&gt;


&lt;p&gt;J'ai donc décidé d'écrire un programme parcourant un dossier (avec plusieurs milliers de fichiers) et de calculer pour toutes les combinaisons des fichiers la distance entre chaque fichier. Ce programme consommant énormément de mémoire, il se peut que pour un grand nombre de fichier, le programme se plante avec une erreur d'allocation de mémoire.&lt;/p&gt;


&lt;p&gt;Ce programme permet de pouvoir faire une cartographie de ces fichiers et ainsi de pouvoir les classer. Testé sur des fichiers textes (sources de logiciels), le programme est assez efficace.&lt;/p&gt;


&lt;p&gt;Testé sur des images, ou des vidéos, les fichiers sont considérés comme tous éloignés les uns des autres, même s'ils sont identiques à  compression différente près, ou s'ils sont identiques à un mouvement près sur la photo (du genre une photo où une même personne se tient dans une position différente).&lt;/p&gt;


&lt;p&gt;Si vous avez une idée sur comment calculer la distance entre deux fichiers déjà compressés (avec perte qui plus est), ca m'intéresse. &lt;img src=&quot;/dotclear/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Comme l'exécution est très lente (compression lzma niveau 9), le programme peut être arrêté et redémarré.&lt;/p&gt;


&lt;p&gt;Pour démarrer le programme, il faut exécuter la commande&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;calcul_distance &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;mon&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;dossier&lt;/pre&gt;


&lt;p&gt;Le programme va alors créer un fichier &lt;code&gt;{5ac1fd3c-504f-4110-9f7e-d6fc89e57bdb}.db&lt;/code&gt; où &lt;code&gt;{5ac1fd3c-504f-4110-9f7e-d6fc89e57bdb}&lt;/code&gt; est différent à chaque nouveau lancement.&lt;/p&gt;


&lt;p&gt;Pour reprendre le traitement où il était, il suffit alors de lancer&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;calcul_distance &lt;span style=&quot;color: #660033;&quot;&gt;--uuid&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;5ac1fd3c-504f-&lt;span style=&quot;color: #000000;&quot;&gt;4110&lt;/span&gt;-9f7e-d6fc89e57bdb&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Si on veut ajouter un dossier au traitement après coup&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;calcul_distance &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nouveau&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;dossier &lt;span style=&quot;color: #660033;&quot;&gt;--uuid&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;5ac1fd3c-504f-&lt;span style=&quot;color: #000000;&quot;&gt;4110&lt;/span&gt;-9f7e-d6fc89e57bdb&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;h3&gt;Exemple&lt;/h3&gt;


&lt;p&gt;Par exemple soit les différentes versions d'un logiciel, mis dans des archives &lt;code&gt;tar&lt;/code&gt;. Pour ne prendre que le code source des versions, on va supprimer tous les fichiers suivants de l'archive &lt;code&gt;tar&lt;/code&gt;&amp;nbsp;: &lt;code&gt;*.jpg, *.png, *.ico, *.qm, *.db&lt;/code&gt;, ... les sources externes à l'application. On ne garde donc que les fichiers textes dont nous avons la possession.&lt;/p&gt;


&lt;p&gt;Après le nettoyage des dossiers&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;$ &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;for&lt;/span&gt; i &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;`&lt;/span&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;`&lt;/span&gt; ; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;do&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;tar&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-c&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$i&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/*&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;$i&lt;/span&gt;.tar
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;done&lt;/span&gt;
$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-l&lt;/span&gt;
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt;,5M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.10.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix 440K  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.4.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix 530K  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.5.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix 610K  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.6.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix 690K  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.7.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;,2M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.8.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;,3M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.6.9.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt;,9M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.7.0.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt;,2M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.7.1.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;,3M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.7.2.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;,3M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.8.0.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;,1M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.8.1_services.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;,1M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.8.1.tar
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; phoenix phoenix &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;,8M  &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; juin  &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt; v0.9.0.tar
$ &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; ..
$ calcul_distance .&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
Step &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; : Create database
Step &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; : Create &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;file&lt;/span&gt; list
Step &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; : Compress single &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;file&lt;/span&gt;                                     
Step &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt; : Compress pair &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;file&lt;/span&gt;                                       
$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt; 
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;051b93a0-d9a9-&lt;span style=&quot;color: #000000;&quot;&gt;4778&lt;/span&gt;-ac73-81ee01a3905d&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;.db
xinx
$ sqlite3 &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;051b93a0-d9a9-&lt;span style=&quot;color: #000000;&quot;&gt;4778&lt;/span&gt;-ac73-81ee01a3905d&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;.db&lt;/pre&gt;


&lt;p&gt;Nous allons maintenant faire une requête dans la base de données sqlite&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;sql sql&quot; style=&quot;font-family:inherit&quot;&gt;$ &lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;TABLES&lt;/span&gt;
distances  files 
$ &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;SELECT&lt;/span&gt; files1&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;path&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; files2&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;path&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; distances&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;distance &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;FROM&lt;/span&gt; distances&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; files files1&lt;span style=&quot;color: #66cc66;&quot;&gt;,&lt;/span&gt; files files2 &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;WHERE&lt;/span&gt; distances&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;id1&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;files1&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;id &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;AND&lt;/span&gt; distances&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;id2&lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt;files2&lt;span style=&quot;color: #66cc66;&quot;&gt;.&lt;/span&gt;id &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;ORDER&lt;/span&gt; &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;BY&lt;/span&gt; distance &lt;span style=&quot;color: #993333; font-weight: bold;&quot;&gt;ASC&lt;/span&gt;;&lt;/pre&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Version 1&lt;/th&gt;&lt;th&gt;Version 2&lt;/th&gt;&lt;th&gt;Distance&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.0350740694634633&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;0.132275346477201&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.142321125298336&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.161719318637048&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;0.196933113059686&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;0.231812199675573&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;0.266593999923953&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.27412838729727&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.312111739912996&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;0.351347925829225&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;0.364115163581424&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.386971922637303&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.401055941017259&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.436705836223058&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.465121645779551&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;0.468472350726879&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.516795574578859&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.51733623689019&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.544376861655528&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;0.558824765667689&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.560609480175814&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;0.594036969567445&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.604226316444666&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.613613062086946&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;0.622950487834501&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.631060763867616&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.632444883185258&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;0.637234847328374&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;0.6494052372746&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.666200571812458&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.678423568871868&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;0.692250570944195&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.701063946130892&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;0.701698986545754&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.717262408423359&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.720311680104721&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;0.738013305804084&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;0.747495551539097&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.747929200720491&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.748031544518325&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.758510349354368&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.767204482779187&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;0.772451857549627&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.796649043913944&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.801221496333008&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.804765901655414&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.819917045496318&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.823540395867048&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.831055117394626&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;0.838850951377793&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.849001032539087&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.853848016623182&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.860291356912217&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.86075956509228&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;0.863340151908353&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.872265541006983&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.873275579233521&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;0.875332023895544&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.87987037883801&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.879941907871053&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.881174812987336&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.886172606121206&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.889515283880001&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;0.892364892140999&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.894375709613201&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.10&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.895694726039398&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.898582911617307&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.7.1&lt;/td&gt;&lt;td&gt;0.902038058337369&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.904821831317442&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.910637046476578&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.7.0&lt;/td&gt;&lt;td&gt;0.918347943544789&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.919716704855963&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.9&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.921714099772221&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.924717744438112&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.8&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.925849165227404&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.7.2&lt;/td&gt;&lt;td&gt;0.928888262611658&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.933685479216414&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.933940067594635&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.939898268404416&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.940789807767177&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.94210246370087&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.946464528845253&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.8.0&lt;/td&gt;&lt;td&gt;0.948830071149278&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.94922082772201&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.951278461132112&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.8.1&lt;/td&gt;&lt;td&gt;0.955572468114482&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.8.1_services&lt;/td&gt;&lt;td&gt;0.95567206186826&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.7&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.96084453455483&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.6&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.964619158469125&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.5&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.965955795849916&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;v0.6.4&lt;/td&gt;&lt;td&gt;v0.9.0&lt;/td&gt;&lt;td&gt;0.968866861905835&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;On peut ainsi voir d'après ce tableau, les versions ayant peu de différences et celles qui ont fait des plus gros bonds en avant.&lt;/p&gt;


&lt;p&gt;On voit ainsi qu'il y a plus de différences entre la version 0.8.0 et la 0.9.0, qu'il y en a eu entre la version 0.6.8 et la 0.6.9.
On peut également voir que les versions 0.6.4 et 0.9.0 n'ont plus rien à voir entre elles.&lt;/p&gt;


&lt;p&gt;Vous pouvez télécharger le logiciel attaché à ce billet.&lt;/p&gt;</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/calcul_distance/calcul_distance.7z"
      length="437666" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2010/06/06/Calcul-de-la-Distance#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2010/06/06/Calcul-de-la-Distance#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/625</wfw:commentRss>
      </item>
    
  <item>
    <title>Présentation de XINX</title>
    <link>http://www.shadoware.org/post/2010/01/13/Presentation_XINX</link>
    <guid isPermaLink="false">urn:md5:0edc55e4ed72a6a0c0e21f3ac74a2c19</guid>
    <pubDate>Sun, 02 May 2010 21:55:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>XINX</category>
        <category>debian</category><category>egx</category><category>generix</category><category>generix group</category><category>libre</category><category>planet</category><category>qt</category><category>stylesheet</category><category>xinx</category><category>xsl</category>    
    <description>&lt;p&gt;Ce billet fait suite à la sortie de la version 0.9.0 de &lt;strong&gt;XINX&lt;/strong&gt; et va vous décrire ce logiciel. &lt;strong&gt;XINX&lt;/strong&gt; est éditeur de feuille de style &lt;em&gt;XSL&lt;/em&gt; (il fait également éditeur &lt;em&gt;JavaScript&lt;/em&gt; et &lt;em&gt;CSS&lt;/em&gt; mais actuellement moins bien que ce que peuvent faire d'autres).&lt;/p&gt;


&lt;p&gt;Il permet l'édition des feuilles de styles en proposant de compléter sur le nom des balises (normal), sur les attributs (normal), sur les valeurs d'attributs&amp;nbsp;: les variables, les paramètres, ... Il propose également automatiquement les différents paramètres lors de l'utilisation d'un &lt;code&gt;call:template&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;L'éditeur est fortement tourné vers l'édition de feuille de style &lt;em&gt;XSL&lt;/em&gt; pour génération d&lt;em&gt;'HTML&lt;/em&gt; mais peut être utilisé pour générer du &lt;em&gt;XML&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/splash.png&quot; alt=&quot;XINX Logo&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;XINX Logo, mai 2010&quot; /&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;    &lt;h3&gt;Historique&lt;/h3&gt;


&lt;p&gt;Depuis un certain temps déjà (5 ans), je travaille pour la société &lt;em&gt;Generix Group&lt;/em&gt; éditant et intégrant un ERP&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2010/01/13/Presentation_XINX#pnote-624-1&quot; id=&quot;rev-pnote-624-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt; du nom de &lt;em&gt;GCE&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Sur la partie Web de cet ERP, il est possible d'intervenir à plusieurs endroits pour modifier son fonctionnement&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le paramétrage (&lt;em&gt;BDD&lt;/em&gt;)&amp;nbsp;: Modification d'un paramètre pour agir sur le comportement du logiciel&lt;/li&gt;
&lt;li&gt;La couche métier (&lt;em&gt;JAVA&lt;/em&gt;)&amp;nbsp;: Lit le paramétrage (&lt;em&gt;BDD&lt;/em&gt;) et réalise les traitements. Il est possible de développer de nouveaux objets, mais aussi de dériver ceux existants.&lt;/li&gt;
&lt;li&gt;La couche de présentation (&lt;em&gt;XSL&lt;/em&gt;)&amp;nbsp;: A l'aide d'un flux de présentation généré par la couche métier et d'un fichier de configuration, présente les données à l'écran.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;La dernière couche est donc l'interprétation d'un flux de donnée, générée à partir de la couche métier (JAVA), à l'aide de feuille de style XSL.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;XINX&lt;/strong&gt; sert à modifier la couche de présentation (&lt;em&gt;XSL&lt;/em&gt;). Sur cette dernière couche, on crée et modifie des feuilles de styles pour modifier la présentation des données à l'écran (Déplacer des champs, supprimer des champs, ajouter des champs, règle de gestion simple ...).&lt;/p&gt;


&lt;p&gt;En mode &lt;em&gt;projet&lt;/em&gt;, chez les clients, les modifications ne sont pas faites directement sur les feuilles de styles standard livrées, mais sur des feuilles de styles dérivées, afin de faciliter les migrations, et la correction des anomalies.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/structure_dossier.png&quot; alt=&quot;Structure dossier &amp;lt;= 140&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; title=&quot;Structure dossier &amp;lt;= 140, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Lors de la modification de feuille de style &lt;em&gt;standard&lt;/em&gt;, il faut alors renommer et placer ce fichier dans un dossier séparé. C'est de cette tâche récurrente qu'est venue la création de l'éditeur de feuille de style &lt;strong&gt;XINX&lt;/strong&gt;.&lt;/p&gt;


&lt;p&gt;Le but était alors, lors de la sauvegarde d'un fichier standard, de proposer automatiquement la sauvegarde dans le bon dossier.&lt;/p&gt;


&lt;p&gt;L'autre point à l'origine de la création de &lt;strong&gt;XINX&lt;/strong&gt; est la non-existence d'un logiciel de développement de feuille de style &lt;em&gt;XSL&lt;/em&gt; gratuit et/ou libre (Il y a bien &lt;em&gt;XML Spy&lt;/em&gt; qui correspondait à peu prés mais qui était payant, et dont nous n'avions pas la licence).&lt;/p&gt;


&lt;p&gt;Sont alors venu s'ajouter d'autres fonctionnalités&amp;nbsp;: la complétion sur les balises, les attributs, les variables, .... &lt;img src=&quot;/dotclear/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;h3&gt;Qu'est que XINX aujourd'hui&amp;nbsp;?&lt;/h3&gt;


&lt;p&gt;&lt;strong&gt;XINX&lt;/strong&gt; prévu initialement comme aide au développement des consultants qui font des développements de feuille de style, est maintenant un éditeur de feuille de style &lt;em&gt;XSL&lt;/em&gt; avec gestion des plugins. L'un des plugins contient des petites fonctionnalités utiles au quotidien par les consultants travaillants sur l'ERP, fonctionnalité auparavant implémenté directement dans le logiciel.&lt;/p&gt;


&lt;p&gt;Dit autrement, cette nouvelle version marque donc une étape&amp;nbsp;: La partie de &lt;strong&gt;XINX&lt;/strong&gt; propre à &lt;em&gt;Generix Group&lt;/em&gt; à été séparée dans un plugin. &lt;strong&gt;XINX&lt;/strong&gt; en lui même n'est alors plus qu'un éditeur de feuille de style, extensible via des plugins, mais il retrouve les mêmes fonctionnalités grâce à ce plugin.&lt;/p&gt;


&lt;h3&gt;Licence&lt;/h3&gt;


&lt;p&gt;&lt;img src=&quot;http://www.gnu.org/graphics/gplv3-127x51.png&quot; alt=&quot;&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;XINX&lt;/strong&gt; est un logiciel libre dont la licence choisie est la GPLv3. Ce qui signifie que vous pouvez&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;télécharger le logiciel&lt;/li&gt;
&lt;li&gt;utiliser le logiciel pour faire ce que vous voulez&lt;/li&gt;
&lt;li&gt;télécharger les sources du logiciels&lt;/li&gt;
&lt;li&gt;modifier les sources du logiciels&lt;/li&gt;
&lt;li&gt;utiliser le logiciel modifié par vos soins&lt;/li&gt;
&lt;li&gt;distribuer le logiciel ou la version modifiée (attention à différencier les parties originales du logiciel avec le bon copyright, et les parties modifiées).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;En tant que logiciel libre &lt;strong&gt;XINX&lt;/strong&gt; possède une plateforme de contribution (ticket, wiki, source, ...) qui se trouve à l'adresse &lt;a href=&quot;http://xinx.shadoware.org&quot; hreflang=&quot;fr&quot;&gt;http://xinx.shadoware.org&lt;/a&gt;. Vous pouvez donc y aller pour contribuer.&lt;/p&gt;


&lt;p&gt;Vous pouvez contribuer de plusieurs façons&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Développement d'un Plugin&lt;/li&gt;
&lt;li&gt;Développement d'un script &lt;em&gt;ECMAScript&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Développement d'un petit patch&lt;/li&gt;
&lt;li&gt;Développement d'un gros patch&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Technologie&lt;/h3&gt;


&lt;p&gt;&lt;strong&gt;XINX&lt;/strong&gt; est un logiciel développé en &lt;em&gt;Qt&lt;/em&gt;. Il compile et tourne sous &lt;em&gt;Gnu/Debian&lt;/em&gt; (normalement n'importe quelle distribution devrait faire l'affaire, mais &lt;em&gt;Gnu/Debian&lt;/em&gt; est la seule distribution testée), et sous &lt;em&gt;MS/Windows&lt;/em&gt;. Il devrait normalement également tourner sous &lt;em&gt;MacOS&lt;/em&gt; (si les dépendances comme les librairies &lt;em&gt;libxml2&lt;/em&gt; et &lt;em&gt;libxslt&lt;/em&gt; sont compilables sous cet OS).&lt;/p&gt;


&lt;p&gt;A chaque version un paquet &lt;em&gt;Gnu/Debian&lt;/em&gt; est mis à disposition sur le dépôt (&lt;code&gt;apt.shadoware.org&lt;/code&gt;) et un binaire &lt;em&gt;MS/Windows&lt;/em&gt; est proposé en téléchargement. &lt;strong&gt;XINX&lt;/strong&gt; est toujours compilable à partir des sources pour les autres distributions ou juste parce que vous préférez ainsi. :D&lt;/p&gt;


&lt;h3&gt;Intégration continue &amp;amp; Tests&lt;/h3&gt;


&lt;p&gt;A chaque &lt;em&gt;validation&lt;/em&gt; sur le référenciel &lt;em&gt;SubVersion&lt;/em&gt;, l'application est compilée et testée (vous pouvez voir le résultat des tests à l'adresse &lt;a href=&quot;http://xinx.shadoware.org/build&quot; hreflang=&quot;fr&quot;&gt;suivante&lt;/a&gt;. A la sortie de la version 0.9.0, les tests couvrent 27% de la librairie principale. Je dois donc encore écrire d'autres jeux de tests.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/.bitten_m.jpg&quot; alt=&quot;Intégration continue&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Intégration continue, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;h3&gt;Code réutilisable pour d'autres projets&lt;/h3&gt;


&lt;p&gt;&lt;strong&gt;XINX&lt;/strong&gt; peut également être intéressant pour d'autres développeurs &lt;em&gt;Qt&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;En effet, vous pouvez trouver dans la dernière version, ainsi que dans les versions précédentes plusieurs classes utilitaires.
Par exemple (liste presque non exhaustive)&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://xinx.shadoware.org/doxygen/devel/html/classTreeProxyItemModel.html&quot; hreflang=&quot;en&quot;&gt;TreeProxyItemModel&lt;/a&gt;&amp;nbsp;: convertit un modèle format table en modèle format arbre. Utile lorsque l'arbre est représenté dans une base de donnée relationnelle par exemple.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://xinx.shadoware.org/doxygen/devel/html/classRecursiveSortFilterProxyModel.html&quot; hreflang=&quot;en&quot;&gt;RecursiveSortFilterProxyModel&lt;/a&gt;&amp;nbsp;: Utilisé pour rechercher facilement des données dans un arbre et permet d'afficher les enfants.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://xinx.shadoware.org/doxygen/devel/html/classXinxLineEdit.html&quot; hreflang=&quot;en&quot;&gt;XinxLineEdit&lt;/a&gt;&amp;nbsp;: Inspiré de KDE, affiche un bouton pour effacer le texte dans la ligne d'édition&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://xinx.shadoware.org/doxygen/devel/html/classXinxListWidgetImpl.html&quot; hreflang=&quot;en&quot;&gt;XinxListWidgetImpl&lt;/a&gt;&amp;nbsp;: Permet de modifier une liste de valeur (ajout, suppression, valeur par défaut, classement, ...)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://xinx.shadoware.org/doxygen/devel/html/classPluginSelector.html&quot; hreflang=&quot;en&quot;&gt;PluginSelector&lt;/a&gt;&amp;nbsp;: Inspiré de KDE, permet d'afficher une liste des plugins, avec un bouton &lt;em&gt;A propos de ...&lt;/em&gt; et un bouton &lt;em&gt;Configurer ...&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://xinx.shadoware.org/doxygen/devel/html/classQMenuView.html&quot; hreflang=&quot;en&quot;&gt;QMenuView&lt;/a&gt;&amp;nbsp;: Inspiré d'un exemple de Qt et permet d'afficher un menu à partir d'un modèle.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Fonctionnalités&lt;/h3&gt;


&lt;h4&gt;Recherche parmi les fichiers d'un dossier&lt;/h4&gt;


&lt;p&gt;Un dock sur le coté permet en mode projet de rechercher et d'ouvrir un fichier parmi une multitude de fichier d'un projet (utile pour les fichiers avec beaucoup de feuille de style).&lt;/p&gt;


&lt;p&gt;La recherche peut se faire avec des Jockers (*)&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/dockprojet.png&quot; alt=&quot;Dock projet&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Dock projet, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;h4&gt;La complétion XSL&lt;/h4&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/.completion_s.jpg&quot; alt=&quot;Completion&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; title=&quot;Completion, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;XINX&lt;/strong&gt; permet  de compléter sur les feuilles de styles à plusieurs niveaux&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2010/01/13/Presentation_XINX#pnote-624-2&quot; id=&quot;rev-pnote-624-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;la balise (fonctionnalité standard vous allez me dire)&amp;nbsp;: &lt;strong&gt;XINX&lt;/strong&gt; permet de compléter sur les balises xsl:, les balises html ...&lt;/li&gt;
&lt;li&gt;les attributs (encore standard). Pour chaque balise, &lt;strong&gt;XINX&lt;/strong&gt; est capable de compléter sur les attributs de la balise saisie.&lt;/li&gt;
&lt;li&gt;les valeurs d'attribut (là c'est intéressant). Permet de compléter sur les variables déclarées dans le fichier &lt;em&gt;XSL&lt;/em&gt;, ainsi que dans les fichiers importés (pour retrouver les fichiers importés, &lt;strong&gt;XINX&lt;/strong&gt;, utilise le mode projet et les paramètres qui y sont définits). De plus sur les attributs non &lt;em&gt;XSL&lt;/em&gt;, &lt;strong&gt;XINX&lt;/strong&gt; ajoute automatiquement les accolades &lt;code&gt;{  }&lt;/code&gt; et les &lt;code&gt;$&lt;/code&gt; pour les variables et les paramètres.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;De plus lors de l'utilisation de la balise call:template, &lt;strong&gt;XINX&lt;/strong&gt; va chercher automatiquement les paramètres (&lt;code&gt;xsl:param&lt;/code&gt;) du template donné, et les ajoute automatiquement en &lt;code&gt;xsl:with-param&lt;/code&gt;.
Pour les balises &lt;code&gt;xsl:apply-templates&lt;/code&gt; &lt;strong&gt;XINX&lt;/strong&gt; propose la liste des modes des templates existants.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/completion2.png&quot; alt=&quot;Completion 2&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Completion 2, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;h4&gt;Le parsing de la feuille de style&lt;/h4&gt;


&lt;p&gt;Fonctionnalité du moment, si vous indiquez un flux de données et une feuille de style, &lt;strong&gt;XINX&lt;/strong&gt; est capable d'afficher le résultat (la source &lt;em&gt;HTML&lt;/em&gt; et le résultat dans un navigateur Webkit)&lt;/p&gt;


&lt;p&gt;Si l'emplacement où doivent s'exécuter les pages est définit alors, les feuilles de styles, les images, ... pourront être affichées.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/.representation_html_m.jpg&quot; alt=&quot;Représentation HTML&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Représentation HTML, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;h3&gt;A venir&lt;/h3&gt;


&lt;p&gt;Bien que l'avenir du logiciel dépend de ces utilisateurs, voici les nouvelles fonctionnalités que devrait apporter la prochaine version&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Déverminage de feuille de style XSL&lt;/li&gt;
&lt;li&gt;Amélioration du parseur JavaScript et CSS&lt;/li&gt;
&lt;li&gt;Quelques réécritures (Vue projet, ...)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Le plugin GCE&lt;/h3&gt;


&lt;p&gt;Comme indiqué ci-dessous, il existe un plugin &lt;em&gt;GCE&lt;/em&gt; utilisé par les consultants travaillants sur l'ERP &lt;em&gt;GCE&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Ce plugin permet de dupliquer une feuille de style d'un dossier à un autre (sans modification des fichiers standards), de lire les dictionnaires de libellé de l'ERP GCE, la lecture du fichier de configuration du lecteur &lt;em&gt;GCE&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xinx/0.9.0/.derivation_m.jpg&quot; alt=&quot;Dérivation de feuille de style&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Dérivation de feuille de style, mai 2010&quot; /&gt;&lt;/p&gt;


&lt;h3&gt;Téléchargement&lt;/h3&gt;


&lt;p&gt;Vous pouvez télécharger &lt;strong&gt;XINX&lt;/strong&gt; à l'adresse &lt;a href=&quot;http://xinx.shadoware.org/downloads&quot; hreflang=&quot;fr&quot;&gt;http://xinx.shadoware.org/downloads&lt;/a&gt; (source et version Windows).&lt;/p&gt;


&lt;p&gt;Si vous voulez installer &lt;strong&gt;XINX&lt;/strong&gt; sur une Gnu/Debian (32 ou 64 bits) vous pouvez inclure le dépôt suivant&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
# Shadoware.Org
deb http://apt.shadoware.org/ squeeze main
&lt;/pre&gt;


&lt;p&gt;Et installé de la façon suivante&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;aptitude&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt; xinx&lt;/pre&gt;


&lt;p&gt;Vous pouvez vous tenir au courant des sorties de version grâce à la &lt;a href=&quot;http://lists.shadoware.org/listinfo/xinx&quot; hreflang=&quot;fr&quot;&gt;mailing list&lt;/a&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2010/01/13/Presentation_XINX#rev-pnote-624-1&quot; id=&quot;pnote-624-1&quot;&gt;1&lt;/a&gt;] Un ERP et un logiciel de gestion d'entreprise. Un ERP permet de gérer, par exemple, les produits, les clients, les fournisseurs, les stocks, les ventes, les achats, la logistique, la comptabilité, .... Je ne vais pas vous faire une présentation des ERPs, car même si cela pourrait faire un billet intéressant, ce n'est pas le but ici.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2010/01/13/Presentation_XINX#rev-pnote-624-2&quot; id=&quot;pnote-624-2&quot;&gt;2&lt;/a&gt;] Merci à &lt;a href=&quot;http://qcodeedit.edyuk.org/&quot; hreflang=&quot;en&quot;&gt;QCodeEdit&lt;/a&gt; qui me fournit quelques fonctionnalités utiles.&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2010/01/13/Presentation_XINX#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2010/01/13/Presentation_XINX#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/624</wfw:commentRss>
      </item>
    
  <item>
    <title>[Qt] Transformation d'une vue tableau en une vue hiérarchique</title>
    <link>http://www.shadoware.org/post/2009/09/10/%5BQt%5D-Transformation-d-une-vue-tableau-en-une-vue-hi%C3%A9rarchique</link>
    <guid isPermaLink="false">urn:md5:a2b92942f5d31facf73b6df365c09893</guid>
    <pubDate>Mon, 21 Sep 2009 13:50:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>C++</category>
        <category>article</category><category>libre</category><category>model</category><category>nokia</category><category>planet</category><category>qt</category><category>trolltech</category>    
    <description>&lt;p&gt;Pour visualiser des données internes à l'écran, Nokia/Qt nous propose l'architecture MVC à l'aide des classes QAbstractItemModel et de ses sous classes (QAbstractListModel, QAbstractTableModel, ...). Le but de l'architecture MVC est de séparer la représentation mémoire des données, de l'affichage qu'elles auront.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/table2tree/mvc1.png&quot; alt=&quot;mvc1.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;mvc1.png, sept. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Si les données sont par exemple issue d'une requête SQL, le modèle QSqlQueryModel permet de représenter la sélection SQL, à l'écran dans un composant QTableView. Ces données sont alors représentées sous forme d'un tableau deux dimensions.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/table2tree/tableau.png&quot; alt=&quot;tableau.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;tableau.png, sept. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Si l'on veut représenter les dossiers de l'ordinateur, le modèle QDirView permet d'afficher les données de façon hiérarchique.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/table2tree/qdirview.png&quot; alt=&quot;qdirview.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;qdirview.png, sept. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Il est également possible d'écrire nos propres modèles pour représenter nos propres données.&lt;/p&gt;


&lt;p&gt;Le but de cet article est de présenter l'écriture d'un modèle, transformant une vue plane (tableau deux dimensions) en vue hiérarchique. Pour cela nous allons prendre l'exemple de l'affichage d'une liste de catégorie&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/09/10/%5BQt%5D-Transformation-d-une-vue-tableau-en-une-vue-hi%C3%A9rarchique#pnote-623-1&quot; id=&quot;rev-pnote-623-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/09/10/%5BQt%5D-Transformation-d-une-vue-tableau-en-une-vue-hi%C3%A9rarchique#rev-pnote-623-1&quot; id=&quot;pnote-623-1&quot;&gt;1&lt;/a&gt;] La construction de notre objet s'est basé sur l'analyse de l'objet QSortFilterProxyModel de Nokia.&lt;/p&gt;&lt;/div&gt;
    &lt;h3&gt;Présentation de l'exemple&lt;/h3&gt;


&lt;p&gt;Nous allons voir ci-dessous comment transformer une vue plane en une vue hiérarchique. Pour cela nous allons prendre l'exemple d'une liste de catégorie. Ces catégories seront stockées dans une base de données Sqlite. Ceci n'a pas d'importance mais permet d'expliquer pourquoi les données en mémoire ne sont pas déjà sous forme hiérarchique.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/table2tree/proxymodel.png&quot; alt=&quot;proxymodel.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;proxymodel.png, sept. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;La description d'une catégorie passe donc par&amp;nbsp;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;un identifiant unique appelé &lt;em&gt;id&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;un nom de catégorie&lt;/li&gt;
&lt;li&gt;un lien vers la catégorie parente appelé &lt;em&gt;parent_id&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;C'est le champ &lt;em&gt;parent_id&lt;/em&gt; qui permettra de déterminer dans quelle catégorie notre sous-catégorie se trouve. Dans notre cas, &lt;em&gt;test3&lt;/em&gt; a comme &lt;em&gt;parent_id&lt;/em&gt; l'identifiant 11 qui est la catégorie &lt;em&gt;test&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Dans notre exemple, nous allons nous conditionner à un modèle en lecture seul. Il est également possible de faire un modèle en lecture/écriture mais nous n'en parlerons pas dans cet article. Nous nous cantonnerons donc à un modèle lecture seul sur un modèle source de type &lt;em&gt;QSqlTableView&lt;/em&gt;. (Un modèle en lecture/écriture peut nécessiter de mettre à jour notre structure, ce qui peut être assez compliqué, par exemple en cas de changement de la catégorie parente).&lt;/p&gt;


&lt;h3&gt;Déclaration d'un modèle&lt;/h3&gt;


&lt;h4&gt;Qu'est qu'un proxy&amp;nbsp;?&lt;/h4&gt;


&lt;p&gt;Notre interface se basera sur la classe &lt;em&gt;QAbstractProxyModel&lt;/em&gt;. Le but de cette classe est de permettre de faire une transposition entre un premier modèle et une vue. Elle peut par exemple (à l'aide de &lt;em&gt;QSortFilterProxyModel&lt;/em&gt;) permettre de filtrer ou trier les données d'une vue.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/table2tree/mvc.png&quot; alt=&quot;mvc.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;mvc.png, sept. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Cette vue nous permettra de faire la transposition entre un modèle tableau et une vue arborescente.&lt;/p&gt;


&lt;h4&gt;Interface du proxy&lt;/h4&gt;


&lt;p&gt;Les méthodes à ré-implémenter pour faire fonctionner une proxy, sont les suivantes&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;virtual QModelIndex index&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; row&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; column&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; QModelIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; parent &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
virtual QModelIndex parent&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; QModelIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; index &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
virtual &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; rowCount&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; QModelIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; parent &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
virtual &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; columnCount&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; QModelIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; parent &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
virtual QModelIndex mapFromSource &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; QModelIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; sourceIndex &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
virtual QModelIndex mapToSource &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; QModelIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; proxyIndex &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Les quatre premières méthodes appartiennent à l'objet &lt;em&gt;QAbstractItemModel&lt;/em&gt; et seront questionnées par la vue (liste, arbre, …) pour connaître la représentation à l'écran.&lt;/p&gt;


&lt;p&gt;Les méthodes &lt;em&gt;mapFromSource()&lt;/em&gt;, et &lt;em&gt;mapToSource()&lt;/em&gt; sont à implémenter pour l'objet &lt;em&gt;QAbstractProxyModel&lt;/em&gt;. Elles permettent de faire la liaison entre les indexes (&lt;em&gt;QModelIndex&lt;/em&gt;) du modèle d'origine et les indexes du nouveau modèle.&lt;/p&gt;


&lt;p&gt;Les méthodes &lt;em&gt;data()&lt;/em&gt;, &lt;em&gt;headerData()&lt;/em&gt;, &lt;em&gt;flags()&lt;/em&gt; sont réimplémentées par l'objet &lt;em&gt;QAbstractProxyModel&lt;/em&gt; et utilisent les méthodes &lt;em&gt;mapFromSource()&lt;/em&gt; et &lt;em&gt;mapToSource()&lt;/em&gt; pour, lors de l'appel d'une de ces méthodes, récupérer les informations stockées sur le modèle d'origine.&lt;/p&gt;


&lt;p&gt;Des méthodes &lt;em&gt;sourceModel()&lt;/em&gt; et &lt;em&gt;setSourceModel()&lt;/em&gt; permettent de spécifier le modèle d'origine.&lt;/p&gt;


&lt;h3&gt;Implémentation de notre modèle&lt;/h3&gt;


&lt;h4&gt;Structure interne&lt;/h4&gt;


&lt;p&gt;Nous allons, dans cette partie, parler de la structure interne utilisée par notre objet.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;struct&lt;/span&gt; Mapping &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; id&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; parrentId&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; index&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; parentIndex&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	QVector&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;int&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; source_rows&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #993333;&quot;&gt;typedef&lt;/span&gt; QMap&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;int&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;Mapping&lt;span style=&quot;color: #339933;&quot;&gt;*&amp;gt;&lt;/span&gt; IndexMap&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
IndexMap m_sourcesIndexMapping&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
QHash&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;int&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;int&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; m_categoryIdMapping&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous allons créer une structure &lt;em&gt;Mapping&lt;/em&gt; qui associera pour une ligne dans le modèle source, les informations concernant&amp;nbsp;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;l'identifiant de la ligne.&lt;/li&gt;
&lt;li&gt;l'identifiant de la ligne parente.&lt;/li&gt;
&lt;li&gt;l'index dans  le modèle source.&lt;/li&gt;
&lt;li&gt;l'index du parent dans le modèle source.&lt;/li&gt;
&lt;li&gt;la liste des indexes dans le modèle source des enfants dans notre modèle.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Une table de hashage permettra de retrouver à partir d'un identifiant (id), la ligne dans le modèle source correspondante. On ne gardera que la seconde colonne (le nom de la catégorie), on ne fera donc l'association qu'entre le nom de la colonne de notre modèle et le modèle source en dure dans le programme.&lt;/p&gt;


&lt;h4&gt;createMapping()&lt;/h4&gt;


&lt;p&gt;Le but de cette méthode est de générer l'arborescence qui sera ensuite utilisée dans la suite des méthodes. Cette arborescence étant générée une fois pour toute (ou à chaque fois que le modèle source sera réinitialisé), il faudra parcourir l'ensemble des lignes du modèle source pour construire notre arbre. Parcourir l'ensemble des lignes du modèle source peut prendre du temps si ce dernier contient beaucoup de ligne.&lt;/p&gt;


&lt;p&gt;Nous allons considérer dans la suite, que l'identifiant de ligne 1 (id) correspond à la catégorie de plus haut niveau (ci-dessus du nom de &lt;em&gt;Categories&lt;/em&gt;). Nous allons créer une catégorie fictive 0 qui correspondra à la racine de notre modèle. Cette catégorie sera donc la catégorie parente de celle à l'identifiant 1.
Dans notre modèle source, la catégorie 0 n'a pas d'équivalence parmi les lignes du modèle source. Nous allons donc lui associer la ligne -1 dans le modèle source.&lt;/p&gt;


&lt;p&gt;Maintenant voyons la génération de la structure interne.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;qDeleteAll&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; m_sourcesIndexMapping &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
m_categoryIdMapping.&lt;span style=&quot;color: #202020;&quot;&gt;clear&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous commençons ci-dessous par nettoyer les différentes structures afin de les régénérer. Il faudra à la suite de la création du mapping appeler la méthode &lt;em&gt;reset()&lt;/em&gt; afin de prévenir la vue que l'ensemble des indexes du modèle sont obsolètes.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; source_rows &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourceModel&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;rowCount&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; source_rows&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;i &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; m &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; new Mapping&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	IndexMap&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #202020;&quot;&gt;const_iterator&lt;/span&gt; it &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; IndexMap&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #202020;&quot;&gt;const_iterator&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;insert&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; m &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;index &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;parrentId &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;parentIndex &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
		QSqlRecord record &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourceModel&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;record&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
		m_categoryIdMapping&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; record.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; list_id &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;toInt&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; i&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
		m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;id &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; record.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; list_id &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;toInt&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt; &lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;// Create the root Item&lt;/span&gt;
		m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;id &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
		m_categoryIdMapping&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous récupérons le nombre de ligne dans le modèle source et commençons à initialiser notre structure. Le but de cette boucle est surtout d'initialiser dans notre correspondance identifiant/index (&lt;em&gt;m_categoryIdMapping&lt;/em&gt;), l'emplacement des identifiants dans notre tableau. Ainsi dans la suite lorsque l'on essaiera d'associer une ligne à son parent, nous pourrons savoir à quel emplacement retrouver notre id dans la structure &lt;em&gt;m_sourcesIndexMapping&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Nous profitons également de cette boucle pour initialiser les différents champs de notre structure comme l'index (qui correspond à la ligne dans le modèle source), et l'id qui correspond à un identifiant unique dans notre liste.&lt;/p&gt;


&lt;p&gt;Nous n'oublions pas notre cas particulier que représente notre racine (ligne source -1 inexistante).&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; i &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; source_rows&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;++&lt;/span&gt;i &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	QSqlRecord record &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourceModel&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;record&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; parentCategoryId &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; record.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; list_parentid &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;toInt&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; parentCategoryIndex &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_categoryIdMapping.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; parentCategoryId&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	Q_ASSERT&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; parentCategoryIndex &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;2&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; mapping &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	mapping&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;parentIndex &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parentCategoryIndex&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	mapping&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;parrentId   &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parentCategoryId&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; categoryMapping &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; parentCategoryIndex &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	categoryMapping&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;append&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; i &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Enfin pour chaque enregistrement de notre modèle source, nous récupérons l'identifiant du parent et   recherchons dans la structure que nous venons de créer l'index dans le modèle source de la  catégorie parente.&lt;/p&gt;


&lt;p&gt;Ces valeurs sont alors renseignées dans le modèle. Nos ajoutons également dans la structure de &lt;em&gt;mapping&lt;/em&gt; de la catégorie parent, notre ligne dans la liste des enfants.&lt;/p&gt;


&lt;p&gt;Notre structure est ainsi complètement initialisé. Un identifiant connaît donc son parent, et la liste de ses enfants. C'est sur cette structure que se basera le reste des méthodes de notre modèle.&lt;/p&gt;


&lt;h4&gt;mapFromSource()&lt;/h4&gt;


&lt;p&gt;Le but de cette méthode est de convertir notre index venant du modèle source vers un index de notre modèle à nous.&lt;/p&gt;


&lt;p&gt;L'index du modèle source nous donne l'emplacement de la donnée dans le modèle source sous forme (ligne, colonne) alors que l'index de notre modèle doit donner l'emplacement dans notre modèle sous la forme (ligne, colonne, pointeur indiquant le parent).&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt; sourceIndex.&lt;span style=&quot;color: #202020;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceIndex.&lt;span style=&quot;color: #202020;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; m_sourceModel &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	qWarning&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;CategoryItemModel: index from wrong model passed to mapFromSource&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il faut donc d'abord vérifier que l'index du modèle source est valide. S'il n'est pas valide, alors il ne sera pas valide non plus dans notre modèle à nous.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; row &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; sourceIndex.&lt;span style=&quot;color: #202020;&quot;&gt;row&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
IndexMap&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #202020;&quot;&gt;const_iterator&lt;/span&gt; it &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constFind&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; row &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
Q_ASSERT&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; it &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constEnd&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous récupérons l'index dans le modèle source, et à l'aide de notre tableau d'index source, nous allons retrouver l'objet &lt;em&gt;Mapping&lt;/em&gt; correspondant. Cette objet &lt;em&gt;Mapping&lt;/em&gt; correspondra à celui de notre index source. Ce dont nous avons besoin pour notre modèle est l'objet &lt;em&gt;Mapping&lt;/em&gt; de l'objet parent (En effet, notre index est construit sous la forme&amp;nbsp;: ligne, colonne, pointeur sur la structure &lt;em&gt;Mapping&lt;/em&gt; du parent de notre index). Nous récupérons donc l'index de la ligne source dans l'objet parent.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; parentRow &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; it.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;parentIndex&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
IndexMap&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #202020;&quot;&gt;const_iterator&lt;/span&gt; parentIt &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constFind&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; parentRow &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
Q_ASSERT&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; parentIt &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constEnd&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; m &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parentIt.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cela nous permet de récupérer l'objet &lt;em&gt;Mapping&lt;/em&gt; de l'index parent.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; proxyRow    &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;indexOf&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; row &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; proxyColumn &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; sourceColumnToProxy&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceIndex.&lt;span style=&quot;color: #202020;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyColumn &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;La méthode &lt;em&gt;sourceColumnToProxy()&lt;/em&gt; permet de transformer une colonne de l'objet source en une colonne de l'objet courant. Cela signifie que la colonne 2 sera convertie en colonne 1, et que les colonnes 1 et 3 ne seront pas converties (et cachées). Dans ce dernier cas, nous retournons &lt;em&gt;QModelIndex()&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;L'index de la ligne dans notre modèle sera donné par la position dans la liste &lt;em&gt;source_rows&lt;/em&gt; dans notre structure de conversion.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; createIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyRow&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; proxyColumn&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;parentIt &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous pouvons alors créer notre index.&lt;/p&gt;


&lt;h4&gt;mapToSource()&lt;/h4&gt;


&lt;p&gt;De la manière inverse à la méthode &lt;em&gt;mapFromSource()&lt;/em&gt;, cette méthode permet de convertir un index de notre objet en un index du modèle source.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt; proxyIndex.&lt;span style=&quot;color: #202020;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyIndex.&lt;span style=&quot;color: #202020;&quot;&gt;model&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; this &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	qWarning&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;CategoryItemModel: index from wrong model passed to mapToSource&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Si le modèle est invalide  dans notre modèle, il l'est aussi dans le modèle source. Il n'y a pas d'équivalent dans le modèle source de l'index racine.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; m &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; static_cast&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;Mapping&lt;span style=&quot;color: #339933;&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyIndex.&lt;span style=&quot;color: #202020;&quot;&gt;internalPointer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous récupérons la structure dans le pointeur interne de notre index.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; sourceColumn &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; proxyColumnToSource&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyIndex.&lt;span style=&quot;color: #202020;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceColumn &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous récupérons également les informations sur notre colonne (Soit, conversion de la colonne 0 dans notre modèle, en la colonne 1 dans le modèle source).&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; sourceRow &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;at&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyIndex.&lt;span style=&quot;color: #202020;&quot;&gt;row&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous recherchons dans notre liste &lt;em&gt;source_rows&lt;/em&gt; la ligne dans le modèle source qui correspond à la ligne (relative au père) indiqué par notre index et nous construisons un index de type (ligne, colonne) correspondant au modèle source.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; m_sourceModel&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;index&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceRow&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; sourceColumn &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;L'implémentation des méthodes &lt;em&gt;mapFromSource()&lt;/em&gt; et &lt;em&gt;mapToSource()&lt;/em&gt; permettent de faire fonctionner les implémentations des méthodes &lt;em&gt;data()&lt;/em&gt;, &lt;em&gt;headerData()&lt;/em&gt;, et &lt;em&gt;flags()&lt;/em&gt;. Il n'y aura donc aucun intérêt à ré-implémenter ces méthodes à moins de vouloir traiter les données de ces fonctions. Nous ne les décrirons donc pas ici, mais vous pourrez voir dans le fichier attaché, un exemple d'utilisation.&lt;/p&gt;


&lt;h4&gt;index()&lt;/h4&gt;

&lt;p&gt;Le principe de cette méthode est de générer un index pour notre modèle. L'index doit être valide et réutilisable dans les méthodes &lt;em&gt;rowCount()&lt;/em&gt;, &lt;em&gt;flags()&lt;/em&gt;, &lt;em&gt;columnCount()&lt;/em&gt;, &lt;em&gt;data()&lt;/em&gt;, &lt;em&gt;mapToSource()&lt;/em&gt;.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; row &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;||&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; column &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Si la ligne ou la colonne est inférieure à 0, l'index n'est pas valide.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;IndexMap&lt;span style=&quot;color: #339933;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #202020;&quot;&gt;const_iterator&lt;/span&gt; it &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constFind&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
QModelIndex sourceParent &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; mapToSource&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; parent &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceParent.&lt;span style=&quot;color: #202020;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	it &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constFind&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceParent.&lt;span style=&quot;color: #202020;&quot;&gt;row&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;A partir de l'index &lt;em&gt;parent&lt;/em&gt; nous retrouvons l'index qui correspond dans le modèle source (&lt;em&gt;sourceParent').  Si l'on ne trouve pas d'index dans le modèle source, nous considérons être sur l'élément racine de notre arbre. Sinon nous recherchons dans la table de &lt;/em&gt;Mapping'' la structure qui correspond.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;Q_ASSERT&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; it &lt;span style=&quot;color: #339933;&quot;&gt;!=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;constEnd&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; it.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;=&lt;/span&gt; row &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Nous vérifions le nombre d'élément dans la structure et nous retournons un index non valide si l'index demandé va au delà de la taille du tableau.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; createIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; row&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; column&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;it &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Finalement nous retournons l'index créé avec le pointeur vers la structure &lt;em&gt;Mapping&lt;/em&gt; du père en &lt;em&gt;internalData&lt;/em&gt;.&lt;/p&gt;


&lt;h4&gt;parent()&lt;/h4&gt;


&lt;p&gt;Cette méthode permet de retourner pour l'index donné du proxy, l'index du parent. Un index invalide n'a pas de parent.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt; index.&lt;span style=&quot;color: #202020;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; m &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; static_cast&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;Mapping&lt;span style=&quot;color: #339933;&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; index.&lt;span style=&quot;color: #202020;&quot;&gt;internalPointer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;On récupère la structure de correspondance stockée dans le pointeur interne de l'objet. Cette  structure nous donne les informations du parent (en effet dans &lt;em&gt;internalPointer()&lt;/em&gt;, on stock la structure &lt;em&gt;Mapping&lt;/em&gt; du parent), et donc l'index dans le modèle source.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; sourceRow &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;index&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceRow &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; QModelIndex&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
QModelIndex sourceParent &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourceModel&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;index&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceRow&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; proxyColumnToSource&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
QModelIndex proxyParent &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; mapFromSource&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceParent &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;On utilise alors notre méthode &lt;em&gt;mapFromSource()&lt;/em&gt; pour retrouver l'index du parent dans le référentiel du proxy.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; proxyParent&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;rowCount()&lt;/h4&gt;


&lt;p&gt;Le but de cette méthode est de retourner le nombre de ligne enfant pour un index. Dans le modèle source les indexes n'ont pas d'enfant.
Lorsque l'index vaut &lt;em&gt;QModelIndex()&lt;/em&gt;, cela signifie qu'il faut retourner le nombre de ligne pour notre racine.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; index.&lt;span style=&quot;color: #202020;&quot;&gt;column&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Seul la première colonne a des enfants.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt; index.&lt;span style=&quot;color: #202020;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; rootMapping &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; rootMapping&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Pour l'index racine, on récupère le nombre de ligne à la ligne -1 du modèle source.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; parrentMapping &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; static_cast&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;Mapping&lt;span style=&quot;color: #339933;&quot;&gt;*&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; index.&lt;span style=&quot;color: #202020;&quot;&gt;internalPointer&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; sourceRowIndex &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parrentMapping&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;at&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; index.&lt;span style=&quot;color: #202020;&quot;&gt;row&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	Mapping &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; rowMapping &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; m_sourcesIndexMapping.&lt;span style=&quot;color: #202020;&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceRowIndex &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; rowMapping&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;source_rows.&lt;span style=&quot;color: #202020;&quot;&gt;count&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Sinon on récupère la structure stockée dans le pointeur interne. Cette structure est celle du parent de notre objet. On récupère à l'aide de la méthode &lt;em&gt;row()&lt;/em&gt; de l'index l'emplacement de la ligne source. Cette ligne source nous permet de récupérer la structure de correspondance de notre index, et ainsi le nombre de ligne de notre index.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;columnCount()&lt;/h4&gt;


&lt;p&gt;Notre modèle ne possède qu'une seule colonne.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;proxyColumnToSource()&lt;/h4&gt;


&lt;p&gt;Si la colonne du proxy vaut 0, alors on retourne la colonne 1, sinon on retourne la colonne -1&amp;nbsp;: la colonne n'est pas convertible, elle n'existe pas dans notre proxy.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; proxyColumn &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; list_name&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;sourceColumToProxy()&lt;/h4&gt;


&lt;p&gt;Si la colonne source est 1, alors nous convertissons celle-ci en la colonne 0. Sinon la colonne n'existe pas dans notre proxy.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; sourceColumn &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; list_name &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;&lt;/pre&gt;</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/qt/table2tree/categoryitemmodel.cpp"
      length="8272" type="text/plain" />
          <enclosure url="http://www.shadoware.org/public/billets/qt/table2tree/categoryitemmodel.h"
      length="3018" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2009/09/10/%5BQt%5D-Transformation-d-une-vue-tableau-en-une-vue-hi%C3%A9rarchique#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/09/10/%5BQt%5D-Transformation-d-une-vue-tableau-en-une-vue-hi%C3%A9rarchique#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/623</wfw:commentRss>
      </item>
    
  <item>
    <title>Parseur XML</title>
    <link>http://www.shadoware.org/post/2009/05/06/Parseur-XML</link>
    <guid isPermaLink="false">urn:md5:c38e3e38c95811c208acff03641cdefb</guid>
    <pubDate>Sun, 31 May 2009 23:13:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Performances</category>
        <category>performance</category><category>planet</category><category>qt</category><category>xml</category>    
    <description>&lt;p&gt;Bonjours à tous,&lt;/p&gt;


&lt;p&gt;L'utilisation des fichiers XML est, à ce jour, un fait dans la plupart des logiciels et est fortement à la mode. Une entreprise qui ne fait pas un peu de XML est souvent &lt;em&gt;has-been&lt;/em&gt;. On utilise alors le XML à bon ou mauvais escient.&lt;/p&gt;    &lt;style&gt;
th {
background-color: #E4E4E4;
weigh: bold;
}
.veryslow {
background-color: #FF0000;
}
.slow {
background-color: #FF8686;
}
.good {
background-color: #C3FFC7;
}
.ignored {
background-color: #E4E4E4;
}
&lt;/style&gt;


&lt;h3&gt;Avantages / Inconvénients&lt;/h3&gt;


&lt;p&gt;Pourquoi utiliser les fichiers XML&amp;nbsp;? Les fichiers XML sont, pour commencer, des fichiers textes, il seront donc toujours lisibles, ce qui garantit une meilleur pérennité de l'information. Les fichiers XML sont structurés hiérarchiquement et suivent une syntaxe stricte. Ainsi le XML est lisible informatiquement par les différents langages de programmation existant, pour organiser vos données, en utilisant différents niveaux. Les fichiers XML peuvent être commenté ce qui peut améliorer la lisibilité pour un humain.&lt;/p&gt;


&lt;p&gt;Le gros inconvénient du XML est sa verbosité. Pour chaque noeud dans la hiérarchie, il y a une balise de début, et une balise de fin contenant le nom de la balise. Le fichier est moins compact que s'il avait été écrit en binaire. Cela peut poser des problèmes comme alourdir les communications réseaux (ex: pour les webservices). Le fichier est aussi plus long à lire qu'un fichier binaire et peut contenir des erreurs.&lt;/p&gt;


&lt;p&gt;Si le fichier n'a pas besoin d'être hiérarchique, il est possible d'utiliser une structure de fichier INI pour ses données.&lt;/p&gt;


&lt;p&gt;Nous nous arrêterons là pour les avantages/inconvénients. L'utilisation ou non d'un fichier XML est ensuite une question (besoin, éthique, ...) à se poser pour ses données et la nécessité de pouvoir les lire autrement que par le programme lui-même.&lt;/p&gt;


&lt;h3&gt;Performance des parseurs.&lt;/h3&gt;


&lt;p&gt;Je me suis amusé à effectuer le test de lecture de différents fichiers de donnée au format XML de taille différentes par une variété de parseur XML en construisant si possible un arbre DOM. Le but est donc de créer un objet par noeud/attribut du fichier XML et de reconstituer la hiérarchie.&lt;/p&gt;


&lt;p&gt;Les parseurs choisis pour ce test sont&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;QtXml&lt;/strong&gt;&amp;nbsp;: Le module XML de la librairie Qt (de la société Nokia)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LibXml2&lt;/strong&gt;&amp;nbsp;: Une librairie C permettant de faire du parsing XML en utilisant DOM ou SAX&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;LibExpat&lt;/strong&gt;&amp;nbsp;: Un parseur orienté flux (plus proche de la méthode SAX que du DOM)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;SCEW&lt;/strong&gt;&amp;nbsp;: Un parseur basé sur Expat générant un arbre DOM (donc un peu plus comparable aux autre parseur).&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;TinyXML&lt;/strong&gt;&amp;nbsp;: Encore un autre parseur XML&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Xerces-C++&lt;/strong&gt;&amp;nbsp;: Le parseur XML d’Apache&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Oracle XML Parser&lt;/strong&gt;&amp;nbsp;: Le parseur d’Oracle propriétaire utiliser dans le serveur d’application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour faire cette suite de benchmark&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/05/06/Parseur-XML#pnote-620-1&quot; id=&quot;rev-pnote-620-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;, j’ai utilisé la librairie QTestLib de Nokia/Qt. Je vous offre donc en avant première le résultat de ce test&amp;nbsp;:&lt;/p&gt;

&lt;table&gt;
&lt;caption&gt;Temps de lecture d'un fichier XML en ms&lt;/caption&gt;
&lt;tr&gt;
  &lt;td/&gt;
  &lt;th&gt;250k&lt;/th&gt;
  &lt;th&gt;9300k&lt;/th&gt;
  &lt;th&gt;11300k&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Qt DOM&lt;/th&gt;
  &lt;td class=&quot;veryslow&quot;&gt;41,42 ms&lt;/td&gt;
  &lt;td class=&quot;veryslow&quot;&gt;2184,34 ms&lt;/td&gt;
  &lt;td class=&quot;veryslow&quot;&gt;2648,71 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;LibXML2&lt;/th&gt;
  &lt;td&gt;16,55 ms&lt;/td&gt;
  &lt;td class=&quot;good&quot;&gt;710,09 ms&lt;/td&gt;
  &lt;td class=&quot;good&quot;&gt;874,42 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Expat (SAX)&lt;/th&gt;
  &lt;td class=&quot;ignored&quot;&gt;5,95 ms&lt;/td&gt;
  &lt;td class=&quot;ignored&quot;&gt;312,02 ms&lt;/td&gt;
  &lt;td class=&quot;ignored&quot;&gt;393,58 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Oracle&lt;/th&gt;
  &lt;td&gt;23,24 ms&lt;/td&gt;
  &lt;td&gt;928,93 ms&lt;/td&gt;
  &lt;td&gt;1135,86 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Scew&lt;/th&gt;
  &lt;td class=&quot;good&quot;&gt;12,05 ms&lt;/td&gt;
  &lt;td&gt;944,37 ms&lt;/td&gt;
  &lt;td&gt;1184,46 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Tiny XML&lt;/th&gt;
  &lt;td class=&quot;slow&quot;&gt;28,91 ms&lt;/td&gt;
  &lt;td class=&quot;slow&quot;&gt;1101,8 ms&lt;/td&gt;
  &lt;td class=&quot;slow&quot;&gt;1369,8 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;th&gt;Xerces (Apache)&lt;/th&gt;
  &lt;td&gt;25,03 ms&lt;/td&gt;
  &lt;td&gt;742,22 ms&lt;/td&gt;
  &lt;td&gt;904,62 ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;



&lt;p&gt;La conclusion de ce résultat signifie que le parseur inclu dans Qt (pour la construction d'un arbre DOM) est très lent ;). Mais pour une utilisation dans une interface graphique, sur de petits fichiers, ne devrait pas poser de problème.&lt;/p&gt;


&lt;p&gt;Enfin le parseur le plus rapide (pour les gros fichiers) est Libxml2. Le parseur C d'oracle, bien que propriétaire n'a rien d'exceptionnel (si on compte avec les problèmes présenté également ci-dessous). Peut-être que la version Java est elle plus performante.&lt;/p&gt;


&lt;p&gt;Vous pouvez retrouver quelques graphiques ci-dessous&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/xmlparser/.TestXMLPerf_m.jpg&quot; alt=&quot;TestXMLPerf.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;TestXMLPerf.png, mai 2009&quot; /&gt;&lt;/p&gt;


&lt;h3&gt;Le source du benchmark&lt;/h3&gt;


&lt;p&gt;Vous pouvez trouver attaché au billet, le source de l'application ayant servi au bench. Pour la partie utilisation du Parseur Oracle, il a fallut contourner plusieurs petits problèmes. Ceci est la joie des librairies propriétaires bien documentées.&lt;/p&gt;


&lt;h4&gt;Compilation avec le XDK 9&lt;/h4&gt;


&lt;p&gt;Lors de la compilation avec le XDK 9, l'application ne dépasse pas le stade du &lt;em&gt;linkage&lt;/em&gt;. Les méthodes sont pourtant bien dans les &lt;em&gt;includes&lt;/em&gt;. De plus les librairies sont bien précisées pour le &lt;em&gt;linkage&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;La définition faite dans le projet est&amp;nbsp;:&lt;/p&gt;
&lt;pre&gt;
XDKPATH = xdk9
XDK_LIB = -lxmlg9 -lxml9 -lxsd9
ORA_LIB = -lcore9 -lnls9 -lunls9 -lcore9 -lnls9 -lcore9
NET_LIB = -lnsl
LIBS += -L$$XDKPATH/lib $$XDK_LIB $$ORA_LIB $$NET_LIB -lpthread
INCLUDEPATH += $$XDKPATH/xdk/include
&lt;/pre&gt;


&lt;p&gt;A la suite de ça, lors de la phase de compilation, on se retrouve avec les messages d'erreurs suivants&amp;nbsp;:&lt;/p&gt;
&lt;pre&gt;
g++ -Wl,-O1 -o xmlparserbenchmark libxml2parser.o expatparser.o xercescppparser.o oracleparser.o qtparser.o scewparser.o tinyparser.o tinyxml.o tinystr.o tinyxmlerror.o tinyxmlparser.o xmlparserbenchmark.o moc_xmlparserbenchmark.o -L/usr/lib -lxml2 -lexpat -lxerces-c -Lxdk9/lib -lxmlg9 -lxml9 -lxsd9 -lcore9 -lnls9 -lunls9 -lcore9 -lnls9 -lcore9 -lnsl -lpthread -Lscew/scew -lscew -lQtTest -lQtXml -lQtGui -lQtCore -lpthread
oracleparser.o: In function `parseWithOracleParser(QString const&amp;amp;)':
oracleparser.cpp:(.text+0x82): undefined reference to `XMLParser::xmlinit(unsigned char*, void (*)(void*, unsigned char const*, unsigned int), void*, xmlsaxcb*, void*, unsigned char*)'
oracleparser.cpp:(.text+0xa8): undefined reference to `XMLParser::xmlparse(unsigned char*, unsigned char*, unsigned int)'
oracleparser.cpp:(.text+0x2b4): undefined reference to `XMLParser::getDocumentElement()'
oracleparser.cpp:(.text+0x2ca): undefined reference to `XMLParser::xmlterm()'
&lt;/pre&gt;


&lt;p&gt;J'ai alors essayé de recompiler les exemples de démonstrations mais là, même problème ...&lt;/p&gt;


&lt;h4&gt;Compilation avec le XDK 10&lt;/h4&gt;


&lt;p&gt;Avec cette version du XDK, nous avons le droit à deux problèmes. Le premier est une grosse fuite mémoire (si on écrit le programme tel que décrit dans la démo), et à un problème d'initialisation du parseur.&lt;/p&gt;


&lt;p&gt;Le code permettant de parser le fichier XML et de générer l'arbre DOM ressemble à ceci&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;CXmlCtx &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; ctxp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
try &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	ctxp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; new CXmlCtx&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; catch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; XmlException &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; e &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;unsigned&lt;/span&gt; ecode &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; e.&lt;span style=&quot;color: #202020;&quot;&gt;getCode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; QString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Failed to initialize XML context, error %1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; ecode &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
Factory&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;CXmlCtx&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;xmlnode&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; fp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
try &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	fp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; new Factory&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;CXmlCtx&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;xmlnode&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; ctxp &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; catch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; FactoryException &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; fe &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;unsigned&lt;/span&gt; ecode &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; fe.&lt;span style=&quot;color: #202020;&quot;&gt;getCode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; QString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Failed to create create parser, error %1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; ecode &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
DOMParser&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;CXmlCtx&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt;xmlnode&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; parserp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
try &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	parserp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; fp&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;createDOMParser&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; DOMParCXml&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; NULL &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; catch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; FactoryException &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; fe &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	delete fp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;unsigned&lt;/span&gt; ecode &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; fe.&lt;span style=&quot;color: #202020;&quot;&gt;getCode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; QString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Failed to create parser, error %1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; ecode &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;char&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; fname &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; filename&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
FileSource &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; isrcp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; new FileSource&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;oratext&lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; fname &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
try &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	DocumentRef&lt;span style=&quot;color: #339933;&quot;&gt;&amp;lt;&lt;/span&gt;xmlnode&lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; docrefp &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; parserp&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;parse&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; isrcp&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; FALSE &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; docrefp &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; NULL &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
		QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; QString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;NULL document&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
	xmlnode &lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt; np &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; docrefp&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;getDocumentElement&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; np &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; NULL &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
		QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; QString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Empty document&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
		&lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
	docrefp&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;markToDelete&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	delete docrefp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; catch&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; ParserException &lt;span style=&quot;color: #339933;&quot;&gt;&amp;amp;&lt;/span&gt; pe &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	delete parserp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	delete isrcp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	delete fp&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #993333;&quot;&gt;unsigned&lt;/span&gt; ecode &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; pe.&lt;span style=&quot;color: #202020;&quot;&gt;getCode&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; QString&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Failed to parse the document, error %1&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;arg&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; ecode &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//	delete parserp;&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//	delete isrcp;&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//	delete fp;&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;//	delete ctxp;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le premier problème se situe lors de la suppression du contexte (dernière ligne, en commentaire). Si cette ligne est exécutée, alors nous avons une grosse erreur de segmentation. J'ai le problème, quels que soient les &lt;code&gt;delete&lt;/code&gt; que je fais avant.
Même en faisant le maximum de &lt;code&gt;delete&lt;/code&gt; (soit parserp, isrcp, fp), le fait de ne pas supprimer le context (ctxp), fait qu'au bout de plusieurs itérations, nous avons une bonne fuite mémoire&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/05/06/Parseur-XML#pnote-620-2&quot; id=&quot;rev-pnote-620-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Vient ensuite le second problème, celui des erreurs d'intialisation. Si le parseur est lancé plusieurs fois de suite, alors l'application affiche les erreurs suivantes à l'écran&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
LPX-00202: Message 202 not found; No message file for product=XDK, facility=LPX
FAIL!  : XmlParserBenchmark::oracleParser(file250k.xml) Failed to parse the document, error 202
   Loc: [oracleparser.cpp(73)]
&lt;/pre&gt;


&lt;p&gt;Aucune explication sur le pourquoi. Parfois ça marche, parfois non... Pour contourner le problème, j'ai forké le parseur pour l'exécuter isolé du reste.&lt;/p&gt;

&lt;pre class=&quot;c c&quot; style=&quot;font-family:inherit&quot;&gt;pid_t pid &lt;span style=&quot;color: #339933;&quot;&gt;=&lt;/span&gt; fork&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; pid &lt;span style=&quot;color: #339933;&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	waitpid&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; pid&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;*&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; pid &lt;span style=&quot;color: #339933;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt; filename.&lt;span style=&quot;color: #202020;&quot;&gt;isEmpty&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;
		parse&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; qPrintable&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; filename &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
	exit&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
	QFAIL&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Cannot fork&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/05/06/Parseur-XML#rev-pnote-620-1&quot; id=&quot;pnote-620-1&quot;&gt;1&lt;/a&gt;] Ces tests ont été réalisé dans un chroot 32-bits allant à 2,4GHz. Les temps sont une moyenne sur 100 itérations&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/05/06/Parseur-XML#rev-pnote-620-2&quot; id=&quot;pnote-620-2&quot;&gt;2&lt;/a&gt;] Si quelqu'un a déjà utilisé ce parseur, et qu'il sait comment il fonctionne, il peut m'écrire&lt;/p&gt;&lt;/div&gt;
</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/xmlparser/benchmark_100iterations.ods"
      length="13231" type="application/vnd.oasis.opendocument.spreadsheet" />
          <enclosure url="http://www.shadoware.org/public/billets/xmlparser/xmlparser-bench.7z"
      length="15716" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2009/05/06/Parseur-XML#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/05/06/Parseur-XML#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/620</wfw:commentRss>
      </item>
    
  <item>
    <title>KMyMoney - Logiciel de compte</title>
    <link>http://www.shadoware.org/post/2009/02/24/KMyMoney-Logiciel-de-compte</link>
    <guid isPermaLink="false">urn:md5:a8f1185e40fdd9ff15ac06145d59a8af</guid>
    <pubDate>Sat, 23 May 2009 12:31:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>argent</category><category>debian</category><category>kde</category><category>libre</category><category>planet</category><category>qt</category>    
    <description>    &lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kmymoney/logo.png&quot; alt=&quot;Logo KMyMoney&quot; style=&quot;float:left; margin: 0 1em 1em 0;&quot; title=&quot;Logo KMyMoney, fév. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Voilà un bon logiciel sur lequel on peut compter (mouarf&amp;nbsp;! mouarf&amp;nbsp;! mouarf !), KMyMoney est un éditeur de compte. Je l'utilise quotidiennement,  et je décide donc d'en parler un peu, pour que d'autres personnes puissent s'intéresser aussi à  ce logiciel.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kmymoney/.Summary_m.jpg&quot; alt=&quot;Summary.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Summary.png, mai 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;KMyMoney est un logiciel de gestion de compte pour particulier. Il vous permet de gérer plusieurs de vos comptes en banque, en vous permettant de saisir les dépenses et les recettes sur chacun de vos comptes.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kmymoney/.Registres_m.jpg&quot; alt=&quot;Registres.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Registres.png, mai 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Vous pouvez également lui indiquer vos échéances (par exemple&amp;nbsp;: forfait téléphone, prêt immobilier&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/24/KMyMoney-Logiciel-de-compte#pnote-615-1&quot; id=&quot;rev-pnote-615-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;, mais aussi salaire, vos virements internes ou externes, ...) qu'il s'occupera de mettre à jour dans le registre automatiquement ou à votre demande.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kmymoney/.Echeancier_m.jpg&quot; alt=&quot;Echeancier.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Echeancier.png, mai 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Après une année d'utilisation, il vous permet également de sortir un rapport détaillé sur vos dépenses et vos recettes suivant les catégories saisies pour vos opérations. Cette information peut vous être très utile pour voir où se trouve le &quot;trou&quot; de votre porte monnaie et ainsi  faire une rustine. Il vous permet aussi de vous projeter vers l'avenir et de faire votre budget pour l'année prochaine. KMyMoney vous offre pour cela, la saisie de votre budget, ainsi que plusieurs rapports d'écart, vous permettant ainsi de retrouver facilement où vous avez finalement dépensé plus que le budget prévu, et où vous avez dépensé moins.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kmymoney/.Rapport_m.jpg&quot; alt=&quot;Rapport.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Rapport.png, mai 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;En plus de vos comptes en banque &lt;em&gt;normaux&lt;/em&gt;, KMyMoney vous permet également de gérer vos comptes titre, et les actions que vous y avez mises. Vous pouvez alors facilement suivre la chute vertigineuse de la bourse et votre portefeuille fondre littéralement, mais aussi la remontée (on espère), des actions d'ici quelques ... siècles.&lt;/p&gt;


&lt;p&gt;Enfin pour les paranos, vos comptes peuvent être cryptés à l'aide de votre clé GnuPG automatiquement par KMyMoney &lt;img src=&quot;/dotclear/themes/default/smilies/smile.png&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kmymoney/.Cryptage_m.jpg&quot; alt=&quot;Cryptage.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Cryptage.png, mai 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Après cette courte présentation, je vous souhaite bon compte &lt;img src=&quot;/dotclear/themes/default/smilies/wink.png&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;blockquote&gt;&lt;p&gt;Pour une vie équilibrée, n'oubliez pas de profiter du soleil, au lieu de passer votre temps sur votre ordinateur&lt;/p&gt;&lt;/blockquote&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/24/KMyMoney-Logiciel-de-compte#rev-pnote-615-1&quot; id=&quot;pnote-615-1&quot;&gt;1&lt;/a&gt;] Il s'occupera d'ailleurs de calculer la durée des échéances, ... en fonction des différents chiffres que vous allez lui entrer.&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2009/02/24/KMyMoney-Logiciel-de-compte#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/02/24/KMyMoney-Logiciel-de-compte#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/615</wfw:commentRss>
      </item>
    
  <item>
    <title>KDE4 devient instable ...</title>
    <link>http://www.shadoware.org/post/2009/04/11/KDE4-passe-dans-sid</link>
    <guid isPermaLink="false">urn:md5:8d9737fde2f18ddfb08a0869850ed3d6</guid>
    <pubDate>Sat, 11 Apr 2009 11:29:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>debian</category><category>kde</category><category>planet</category><category>qt</category>    
    <description>    &lt;p&gt;Titre trolleur, cela ne veux pas dire que KDE 4 est moins stable qu'avant mais qu'il a passé une étape supplémentaire chez Debian.&lt;/p&gt;


&lt;p&gt;Voilà quelques jours déjà que la distribution &lt;strong&gt;Gnu/Debian&lt;/strong&gt; intègre &lt;strong&gt;KDE 4&lt;/strong&gt; dans sa version instable. C'est une grande nouvelle car cela va permettre à toute les personnes se trouvant en instable et n'ayant pas touchées à la branche expérimental de Debian de pouvoir tester &lt;strong&gt;KDE 4&lt;/strong&gt;.&lt;/p&gt;


&lt;p&gt;Malheureusement pour les &lt;em&gt;traumatisé de KDE 4&lt;/em&gt;, l'intégration de ce dernier remplace KDE 3.5 et ne viens pas se positionner en parallèle. Il me semble pourtant que lors du passage de KDE 2 à KDE 3, il était possible d'avoir les deux bureaux en même temps sur sa machine et de switcher de l'un à l'autre sans difficulté. Cela signifie donc peut-être aussi la perte d'utilisateur pour KDE sous Gnu/Debian au profit d'un autre environnement de bureau.&lt;/p&gt;


&lt;p&gt;Afin d'effectuer la migration en douceur, Gnu/Debian propose un assistant de migration de KDE du nom de Kaboom. Cet assistant, démarrer lors de la première connexion de l'utilisateur et vous propose alors de sauvegarder votre ancien dossier de configuration KDE 3 et de migrer le dossier .kde vers la version 4.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kaboom/.kaboom1_s.jpg&quot; alt=&quot;kaboom1.png&quot; title=&quot;kaboom1.png, avr. 2009&quot; /&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kaboom/.kaboom2_s.jpg&quot; alt=&quot;kaboom2.png&quot; title=&quot;kaboom2.png, avr. 2009&quot; /&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/kaboom/.kaboom3_s.jpg&quot; alt=&quot;kaboom3.png&quot; title=&quot;kaboom3.png, avr. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Je viens donc de passer à KDE 4 et m'émerveille des nouvelles fonctionnalités de KWin (cube, placement des fenêtres) que je n'avais pas avant, car n'avait jamais installé Compiz ...&lt;/p&gt;


&lt;p&gt;Bonne installation,&lt;/p&gt;</description>
    
    
    
          <comments>http://www.shadoware.org/post/2009/04/11/KDE4-passe-dans-sid#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/04/11/KDE4-passe-dans-sid#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/619</wfw:commentRss>
      </item>
    
  <item>
    <title>Qt 4.5 est sortie</title>
    <link>http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie</link>
    <guid isPermaLink="false">urn:md5:64ae6f28b3981e32fa5d8e9568c8220c</guid>
    <pubDate>Tue, 03 Mar 2009 16:42:00 +0100</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>kde</category><category>nokia</category><category>planet</category><category>qmake</category><category>qt</category>    
    <description>    &lt;p&gt;Voilà quelques heures que la dernière version de &lt;em&gt;Qt&lt;/em&gt; est sortie. Cette version, numéroté 4.5, est essentiellement orienté performance.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/logo_nokia_qt.png&quot; alt=&quot;Logo Nokia/Qt&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Logo Nokia/Qt, fév. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Elle contient entre autre &lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie#pnote-617-1&quot; id=&quot;rev-pnote-617-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Une mise à jour de &lt;em&gt;QtWebKit&lt;/em&gt; vers un version de &lt;em&gt;WebKit&lt;/em&gt; plus récente (avec un nouveau moteur JavaScript plus rapide, la possibilité d'ajouter des greffons comme &lt;em&gt;Flash&lt;/em&gt;...). Il est également possible d'utiliser les balises d'HTML 5.&lt;/li&gt;
&lt;li&gt;Amélioration des performances sur le moteur de rendu ainsi que sur le rendu du texte. Une librairie permettant de faire des tests de performance a été incluse&amp;nbsp;: &lt;em&gt;QtBenchLib&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Le support de &lt;em&gt;Mac OS X Cocoa&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;La possibilité de faire des transformations XSLT&lt;/li&gt;
&lt;li&gt;Un débuggeur &lt;em&gt;QtScript&lt;/em&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie#pnote-617-2&quot; id=&quot;rev-pnote-617-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/qtscript-debugger-small.png&quot; alt=&quot;Qt Script Debuger&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Qt Script Debugger, mar. 2009&quot; /&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Le support du format &lt;em&gt;OpenDocument&lt;/em&gt; (ODF version 1.0, ne supportant que le texte et les images)&lt;/li&gt;
&lt;li&gt;Amélioration du support des proxys&lt;/li&gt;
&lt;li&gt;Amélioration de &lt;em&gt;QtDesigner&lt;/em&gt;, &lt;em&gt;QtLinguist&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Une meilleur intégration au thème Gtk&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Cette nouvelle version apporte également une grande nouveauté puisqu'elle est &lt;em&gt;LGPL&lt;/em&gt;. Il est donc désormais possible de faire une application propriétaire à l'aide de cette librairie sans prendre une licence chez &lt;em&gt;Qt Software&lt;/em&gt;. Par contre si une entreprise souhaite un support pour la librairie, il faudra tout de même acheter une licence.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/.ScreenShot166_s.jpg&quot; alt=&quot;Téléchargement de Qt 4.5&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; title=&quot;Téléchargement de Qt 4.5, mar. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;La sortie de &lt;em&gt;Qt&lt;/em&gt; 4.5 est accompagné de &lt;em&gt;Qt Creator&lt;/em&gt; 1.0. &lt;em&gt;Qt Creator&lt;/em&gt; est l'outil dernier né de chez &lt;em&gt;Qt Software&lt;/em&gt; (branche de &lt;em&gt;Nokia&lt;/em&gt;) et est un IDE de développement de programme &lt;em&gt;Qt&lt;/em&gt;. Un paquet est proposé contenant &lt;em&gt;Qt&lt;/em&gt;, &lt;em&gt;Qt Creator&lt;/em&gt;, ainsi que &lt;em&gt;MinGW&lt;/em&gt; et permettant d'avoir une installation tout en un d'un poste de développement.&lt;/p&gt;


&lt;p&gt;Vous pouvez donc aller télécharger la dernière version de &lt;em&gt;Qt&lt;/em&gt;, ainsi que de &lt;em&gt;Qt Creator&lt;/em&gt; (attention les serveurs sont surchargés) à cette &lt;a href=&quot;http://www.qtsoftware.com/downloads&quot; hreflang=&quot;fr&quot;&gt;adresse&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Je remercie toute l'équipe de nouvellement &lt;em&gt;Qt Software&lt;/em&gt; de cette nouvelle version.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie#rev-pnote-617-1&quot; id=&quot;pnote-617-1&quot;&gt;1&lt;/a&gt;] pour plus de détail voir &lt;a href=&quot;http://doc.trolltech.com/4.5/qt4-5-intro.html&quot; hreflang=&quot;fr&quot;&gt;http://doc.trolltech.com/4.5/qt4-5-intro.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie#rev-pnote-617-2&quot; id=&quot;pnote-617-2&quot;&gt;2&lt;/a&gt;] L'image du debugger viens du site &lt;em&gt;Qt Software&lt;/em&gt;&lt;/p&gt;&lt;/div&gt;
</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/qt/changes-4.5"
      length="59463" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/03/03/Qt-4.5-est-sortie#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/617</wfw:commentRss>
      </item>
    
  <item>
    <title>Outil de sécurisation non intéropérable</title>
    <link>http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable</link>
    <guid isPermaLink="false">urn:md5:5c2323fdd9ea7da2557b9263608d3fbe</guid>
    <pubDate>Fri, 20 Feb 2009 10:00:00 +0100</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>APRIL</category><category>contre-façon</category><category>libre</category><category>musique</category><category>planet</category><category>vie</category>    
    <description>    &lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/piracy/DooFi_Skull.png&quot; alt=&quot;Piracy&quot; style=&quot;float:left; margin: 0 1em 1em 0;&quot; title=&quot;Piracy, fév. 2009&quot; /&gt; Alors que l'UMP est accusé de contrefaçon du groupe MGMT&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#pnote-614-1&quot; id=&quot;rev-pnote-614-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;, et est donc accusé du terme de &lt;em&gt;piratage&lt;/em&gt; selon le mot utilisé à mauvais escient, nous avons des nouvelles sur le logiciel espion du gouvernement&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#pnote-614-2&quot; id=&quot;rev-pnote-614-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Ce dernier sera non seulement payant mais également non interopérable. Pour &lt;em&gt;le rapporteur Riester&lt;/em&gt;, l'interopérabilité est un frein au choix et n'est pas nécessaire&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;q&gt;Je n’y suis pas favorable, a-t-il expliqué avant de poursuivre il faut laisser au consommateur sa totale liberté de choix en fonction de son système d’exploitation. L’interopérabilité n’est pas nécessaire pour les consommateurs et elle est trop contraignante pour les éditeurs de logiciels&lt;/q&gt;&lt;/p&gt;


&lt;blockquote&gt;&lt;p&gt;les moyens de sécurisation mis en place ne sauraient être gratuits, à l’image des logiciels de contrôle parental, mis à la disposition des consommateurs à titre payant, même si leur prix est modique&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;En plus de l'abonnement internet et du modem ADSL de l'opérateur, il faudra également donc s'acheter ce logiciel espion, ainsi que le système d'exploitation &lt;em&gt;Redmondien&lt;/em&gt; qui va avec. En effet, aucun éditeur de logiciel ne trouvera un intérêt (monétaire) à développer un tel logiciel espion (qui sera, de surcroit, à source fermé) pour un système d'exploitation libre.
Comment donc pourrions-nous nous défendre, nous utilisateurs du logiciel libre, si vis-à-vis de la loi, nous ne pourrons nous justifier d'un téléchargement illégal même s'il n'en est pas le cas.&lt;/p&gt;


&lt;p&gt;Alors que l'on parle de vente lié, &lt;em&gt;M. Henrard&lt;/em&gt; répond &lt;q&gt;On crée une incitation et chacun se détermine en fonction de ses obligations. Il y a des aléas dont on veut se protéger et si on est un tout petit peu rationnel, il est évident qu’on va demander à son FAI l’utilisation d’un tel dispositif.&lt;/q&gt; et donc payer ...&lt;/p&gt;


&lt;p&gt;Le président de l&lt;em&gt;'APRIL&lt;/em&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#pnote-614-3&quot; id=&quot;rev-pnote-614-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt; s'insurge qu'&lt;q&gt;il reste encore à l'Assemblée nationale des députés qui sont opposés à l'interopérabilité, opposés à la libre concurrence, opposés au libre-choix des utilisateurs, et opposés au logiciel libre&lt;/q&gt;&lt;/p&gt;


&lt;p&gt;Quand au logiciel en lui-même, personne ne connait son fonctionnement&amp;nbsp;:
- Qu'enverra-t-il comme donnée&amp;nbsp;?
- A qui enverra-t-il les données (au FAI&amp;nbsp;? au gens plein de fric (major)&amp;nbsp;? au marketing&amp;nbsp;? au gouvernement&amp;nbsp;? à tout ces gens ?)
- Devras-t-il être sur chaque ordinateur (avec une licence par ordinateur à payer)&amp;nbsp;? Sur le modem ADSL&amp;nbsp;? Sur un seul des ordinateurs (et il nous sera alors interdis d'avoir plus d'un ordinateur par foyer)&amp;nbsp;?&lt;/p&gt;



&lt;p&gt;La France apparaitra alors surement bientôt (pour 2009) dans les pays ennemis d'Internet&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#pnote-614-4&quot; id=&quot;rev-pnote-614-4&quot;&gt;4&lt;/a&gt;]&lt;/sup&gt;. Vive la république et vive la France.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#rev-pnote-614-1&quot; id=&quot;pnote-614-1&quot;&gt;1&lt;/a&gt;] http://www.lexpress.fr/culture/musique/l-ump-a-t-il-pirate-mgmt_742192.html&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#rev-pnote-614-2&quot; id=&quot;pnote-614-2&quot;&gt;2&lt;/a&gt;] http://www.pcinpact.com/actu/news/49218-hadopi-interoperabilite-logiciel-libre-payant.htm?vc=1&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#rev-pnote-614-3&quot; id=&quot;pnote-614-3&quot;&gt;3&lt;/a&gt;] Benoît Sibaud, président de l&lt;em&gt;'APRIL&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#rev-pnote-614-4&quot; id=&quot;pnote-614-4&quot;&gt;4&lt;/a&gt;] http://fr.wikipedia.org/wiki/Internet_et_la_censure#Les_ennemis_d.E2.80.99Internet&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/02/20/Outil-de-s%C3%A9curisation-non-int%C3%A9rop%C3%A9rable#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/614</wfw:commentRss>
      </item>
    
  <item>
    <title>Debian Lenny est sortie</title>
    <link>http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie</link>
    <guid isPermaLink="false">urn:md5:1de72db849f36d393c469df0b42620f2</guid>
    <pubDate>Sun, 15 Feb 2009 11:41:00 +0000</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>debian</category><category>kde</category><category>planet</category>    
    <description>    &lt;p&gt;Bonjours à tous,&lt;/p&gt;


&lt;p&gt;Voici la grande nouvelle de ce Week-End&amp;nbsp;:
Hier, le jour de la &lt;strong&gt;St Valentin&lt;/strong&gt;, la distribution stable &lt;strong&gt;Gnu/Debian&lt;/strong&gt; est passé de &lt;strong&gt;Etch&lt;/strong&gt; à &lt;strong&gt;Lenny&lt;/strong&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie#pnote-612-1&quot; id=&quot;rev-pnote-612-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/lenny/debian-logo.png&quot; alt=&quot;Logo Debian&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;Logo Debian, fév. 2009&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Cela annonce donc non seulement une nouvelle version stable de &lt;strong&gt;Gnu/Debian&lt;/strong&gt; (ce qui est loin d'arriver tous les jours) mais aussi le déblocage de &lt;strong&gt;sid&lt;/strong&gt;.&lt;/p&gt;


&lt;p&gt;Attention lors des prochaines mises à jour, &lt;strong&gt;KDE 4&lt;/strong&gt; (ainsi que les dernières versions de tous les logiciels) arrivera doucement sur votre bureau&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie#pnote-612-2&quot; id=&quot;rev-pnote-612-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt; si vous êtes en &lt;strong&gt;sid&lt;/strong&gt; ou en &lt;strong&gt;testing&lt;/strong&gt;. Cela va de même pour les dernières versions du noyau qui devrait arriver également.&lt;/p&gt;


&lt;p&gt;La prochaine, future distribution stable (qui apparaîtra sûrement d'ici 5 ans) sera &lt;strong&gt;squeeze&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie#rev-pnote-612-1&quot; id=&quot;pnote-612-1&quot;&gt;1&lt;/a&gt;] http://blog.ganneff.de/blog/2009/02/14/lenny-release.html&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie#rev-pnote-612-2&quot; id=&quot;pnote-612-2&quot;&gt;2&lt;/a&gt;] http://pusling.com/blog/?p=94&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2009/02/15/Debian-Lenny-est-sortie#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/612</wfw:commentRss>
      </item>
    
  <item>
    <title>Email2Trac</title>
    <link>http://www.shadoware.org/post/2008/10/21/Email2Trac</link>
    <guid isPermaLink="false">urn:md5:5ec8ea26412295d7bc4b6d2846dff997</guid>
    <pubDate>Wed, 22 Oct 2008 09:00:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>article</category><category>bug</category><category>debian</category><category>dédié</category><category>mail</category><category>planet</category><category>trac</category>    
    <description>&lt;p&gt;&lt;em&gt;Email2Trac&lt;/em&gt; est un logiciel permettant de créer un ticket sous &lt;em&gt;Trac&lt;/em&gt; en envoyant un mail au système de suivi de ticket.&lt;/p&gt;


&lt;p&gt;L'intérêt d'envoyer un mail au système de suivi plutôt que de se connecter sur le site Internet pour faire ses rapports d'anomalie, est de faciliter l'accès à de nouvelles personnes.
En effet, il est parfois plus facile d'envoyer un mail avec son client mail préféré (en considérant que le logiciel est quasiment toujours ouvert, ce qui doit être le cas en entreprise) que d'ouvrir le navigateur pour envoyer une anomalie de temps en temps (ouvrir le site, se logger, remplir tous les champs, ...).&lt;/p&gt;


&lt;p&gt;Ceci peut également être utilisé par un outil de rapport de bug, envoyant un mail automatique (avec confirmation de l'utilisateur) au crash dudit logiciel.&lt;/p&gt;    &lt;p&gt;Comme dit précédemment, &lt;em&gt;EMail2Trac&lt;/em&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/10/21/Email2Trac#pnote-611-1&quot; id=&quot;rev-pnote-611-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt; permet&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;d'ajouter un ticket en envoyant un mail, avec des fichiers attachés&lt;/li&gt;
&lt;li&gt;mettre à jour un ticket (en répondant au mail du ticket par exemple)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Installation&lt;/h3&gt;


&lt;p&gt;Pour installer &lt;em&gt;Email2Trac&lt;/em&gt;, il faut télécharger le &lt;a href=&quot;ftp://ftp.sara.nl/pub/outgoing/email2trac.tar.gz&quot;&gt;source&lt;/a&gt; et le décompresser dans un dossier temporaire (ou utilisateur).&lt;/p&gt;


&lt;h4&gt;Sans gestionnaire de paquet&lt;/h4&gt;


&lt;p&gt;Ensuite la compilation se fait à l'aide des habituelles &lt;code&gt;autotools&lt;/code&gt;&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;configure &lt;span style=&quot;color: #660033;&quot;&gt;--prefix&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;local&lt;/span&gt; --with-mta_user=nobody --with-trac_user=www-data
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; 
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Sous Debian&lt;/h4&gt;


&lt;p&gt;Après avoir installé les paquets &lt;code&gt;cdbs&lt;/code&gt; et &lt;code&gt;autotools-dev&lt;/code&gt;, vous pouvez exécuter les commandes suivante en &lt;em&gt;root&lt;/em&gt; (ou la première à l'aide de &lt;em&gt;fakeroot&lt;/em&gt;)&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;rules binary
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;dpkg&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-i&lt;/span&gt; ..&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;email2trac_&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt;version&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt;.deb&lt;/pre&gt;


&lt;p&gt;Pour le gestionnaire de paquets &lt;em&gt;RPM&lt;/em&gt; vous pouvez visiter la page &lt;a href=&quot;https://subtrac.sara.nl/oss/email2trac/wiki/Email2tracInstallation&quot; hreflang=&quot;en&quot;&gt;https://subtrac.sara.nl/oss/email2trac/wiki/Email2tracInstallation&lt;/a&gt;&lt;/p&gt;


&lt;h3&gt;Configuration de l'application&lt;/h3&gt;


&lt;p&gt;La deuxième étape est l'édition du fichier &lt;code&gt;/etc/email2trac.conf&lt;/code&gt;. Dans ce fichier les informations à renseigner concerne la gestion du projet Trac&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/10/21/Email2Trac#pnote-611-2&quot; id=&quot;rev-pnote-611-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt; par &lt;em&gt;Email2Trac&lt;/em&gt;.&lt;/p&gt;

&lt;pre class=&quot;ini ini&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #000066; font-weight:bold;&quot;&gt;&lt;span style=&quot;&quot;&gt;&amp;#91;&lt;/span&gt;DEFAULT&lt;span style=&quot;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/span&gt;
project: /www/site/trac/projet1
spam_level: &lt;span style=&quot;&quot;&gt;5&lt;/span&gt;
drop_spam: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;
ticket_update: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;
strip_signature: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #000066; font-weight:bold;&quot;&gt;&lt;span style=&quot;&quot;&gt;&amp;#91;&lt;/span&gt;projet2&lt;span style=&quot;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;/span&gt;
project: /www/site/trac/projet2
spam_level: &lt;span style=&quot;&quot;&gt;5&lt;/span&gt;
drop_spam: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;
ticket_update: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;
strip_signature: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Les différentes options dépendent de ce que vous souhaitez avoir. Les différentes possibilités sont à l'adresse &lt;a href=&quot;https://subtrac.sara.nl/oss/email2trac/wiki/Email2tracConfiguration&quot; hreflang=&quot;en&quot;&gt;suivante&lt;/a&gt;.&lt;/p&gt;


&lt;h4&gt;Spam&lt;/h4&gt;


&lt;p&gt;La gestion du SPAM se fait à l'aide des 3 lignes&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;ini ini&quot; style=&quot;font-family:inherit&quot;&gt;spam_level: &lt;span style=&quot;&quot;&gt;5&lt;/span&gt;
drop_spam: &lt;span style=&quot;&quot;&gt;1&lt;/span&gt;
spam_header: X-Spam-Level&lt;/pre&gt;


&lt;p&gt;La ligne &lt;code&gt;spam_header&lt;/code&gt; étant à configurer suivant votre politique de gestion des spams (utilisation de &lt;em&gt;SpamAssassin&lt;/em&gt; ou d'un autre utilitaire).&lt;/p&gt;


&lt;h3&gt;Configuration de Postfix&lt;/h3&gt;


&lt;p&gt;Il faut maintenant configurer notre système de messagerie pour intégrer &lt;em&gt;Email2Trac&lt;/em&gt;. Nous allons détailler ici la mise en place de &lt;em&gt;Email2Trac&lt;/em&gt; sous &lt;em&gt;Postfix&lt;/em&gt;. Pour les autres serveurs mails vous pouvez visiter la page&amp;nbsp;: &lt;a href=&quot;http://www.shadoware.org/post/2008/10/21/en&quot;&gt;http://subtrac.sara.nl/oss/email2trac/wiki/Email2tracMta&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;Aliases&lt;/h4&gt;


&lt;p&gt;La première méthode concerne la modification du fichier des &lt;em&gt;alias&lt;/em&gt; pour une configuration standard de &lt;em&gt;postfix&lt;/em&gt;.  Nous allons commencer par modifier le fichier &lt;code&gt;/etc/aliases&lt;/code&gt; en ajoutant la ligne suivante (pour le projet 1)&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
projet1: |&amp;quot;/usr/bin/run_email2trac&amp;quot;
&lt;/pre&gt;


&lt;p&gt;Il est également possible de préciser le projet sur lequel il faut travailler (projet définit dans &lt;code&gt;/etc/email2trac.conf&lt;/code&gt;)&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
projet2: |&amp;quot;/usr/bin/run_email2trac --project=projet2 --ticket_prefix=devel&amp;quot;
&lt;/pre&gt;


&lt;p&gt;Dans le fichier &lt;code&gt;/etc/postfix/main.cf&lt;/code&gt;, il faut avoir défini l'emplacement des alias de la manière suivante&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;ini ini&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #000099;&quot;&gt;alias_maps&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight:bold;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #660066;&quot;&gt; hash:/etc/aliases&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Les commandes suivantes permettent de mettre à jour le fichier des alias et demander à &lt;em&gt;Postfix&lt;/em&gt; de recharger la configuration&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;postaliases &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;aliases
postfix reload&lt;/pre&gt;


&lt;p&gt;Une fois ceci terminé, les mails envoyé à &lt;em&gt;projet1@domain.org&lt;/em&gt; et &lt;em&gt;projet2@domaine.org&lt;/em&gt; seront automatiquement redirigés vers &lt;em&gt;email2trac&lt;/em&gt; qui s'occupera de créer le ticket dans votre système de suivi.&lt;/p&gt;


&lt;h4&gt;Transport&lt;/h4&gt;


&lt;p&gt;Cette configuration concerne les personnes qui ont une configuration plus complexe de &lt;em&gt;postfix&lt;/em&gt; par exemple en gérant des domaines virtuels. Il est alors possible de définir une redirection des tickets pour un sous domaine.&lt;/p&gt;


&lt;p&gt;Nous avons donc créé le sous-domaine &lt;em&gt;tickets.domaine.org&lt;/em&gt; et voulons que les mails envoyés à &lt;em&gt;projet1@tickets.domaine.org&lt;/em&gt; est &lt;em&gt;projet2@tickets.domaine.org&lt;/em&gt; soient redirigés vers email2trac.&lt;/p&gt;


&lt;p&gt;Pour cela nous allons créer un fichier &lt;code&gt;/etc/postfix/transport&lt;/code&gt; avec les lignes ci-dessous&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
projet1@tickets.domaine.org      projet1:
projet2@tickets.domaine.org      projet2:
&lt;/pre&gt;


&lt;p&gt;Puis dans le fichier &lt;code&gt;/etc/postfix/main.cf&lt;/code&gt; nous allons définir que pour le sous domaine &lt;em&gt;tickets.domaine.org&lt;/em&gt;, il faut lire et utiliser le fichier des transports. (Attention il ne faut pas ajouter ce sous-domaine dans &lt;code&gt;mydestination&lt;/code&gt;.&lt;/p&gt;

&lt;pre class=&quot;ini ini&quot; style=&quot;font-family:inherit&quot;&gt;&lt;span style=&quot;color: #000099;&quot;&gt;relay_domains&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight:bold;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #660066;&quot;&gt; tickets.domaine.org&lt;/span&gt;
&lt;span style=&quot;color: #000099;&quot;&gt;transport_maps&lt;/span&gt; &lt;span style=&quot;color: #000066; font-weight:bold;&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color: #660066;&quot;&gt; hash:/etc/postfix/transport&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ensuite, il nous faut définir dans le fichier &lt;code&gt;/etc/postfix/master.cf&lt;/code&gt; notre nouveau mode de transport. Il n'est pas obligé d'utiliser &lt;code&gt;run_email2trac&lt;/code&gt; qui fait un changement d'utilisateur, car dans le fichier &lt;code&gt;master.cf&lt;/code&gt; on peut directement définir l'utilisateur de destination.&lt;/p&gt;

&lt;pre&gt;
projet1      unix  -       n       n       -       -       pipe
  flags=FR user=www-data argv=/usr/bin/email2trac
  ${nexthop} ${user}
projet2      unix  -       n       n       -       -       pipe
  flags=FR user=www-data argv=/usr/bin/email2trac
  ${nexthop} ${user}
&lt;/pre&gt;


&lt;p&gt;Enfin il faut redémarrer &lt;em&gt;postfix&lt;/em&gt;&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;postmap &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;postfix&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;transport
postfix reload&lt;/pre&gt;


&lt;p&gt;Et voilà vous pouvez envoyer vos mails à &lt;em&gt;projet1@tickets.shadoware.org&lt;/em&gt;.&lt;/p&gt;



&lt;h3&gt;Tester&lt;/h3&gt;


&lt;p&gt;Pour tester il est possible d'envoyer un mail, comme ceci&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;mail projet1&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;tickets.shadoware.org &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt; ticket.txt&lt;/pre&gt;


&lt;p&gt;En cas de problème, vous pouvez vérifier que email2trac est bien configuré avec la commande&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;email2trac &lt;span style=&quot;color: #660033;&quot;&gt;--project&lt;/span&gt;=projet1 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;&lt;/span&gt; ticket.txt&lt;/pre&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/10/21/Email2Trac#rev-pnote-611-1&quot; id=&quot;pnote-611-1&quot;&gt;1&lt;/a&gt;] &lt;a href=&quot;http://subtrac.sara.nl/oss/email2trac/wiki&quot; title=&quot;http://subtrac.sara.nl/oss/email2trac/wiki&quot;&gt;http://subtrac.sara.nl/oss/email2tr...&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/10/21/Email2Trac#rev-pnote-611-2&quot; id=&quot;pnote-611-2&quot;&gt;2&lt;/a&gt;] &lt;a href=&quot;http://trac.edgewall.org/&quot; title=&quot;http://trac.edgewall.org/&quot;&gt;http://trac.edgewall.org/&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2008/10/21/Email2Trac#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2008/10/21/Email2Trac#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/611</wfw:commentRss>
      </item>
    
  <item>
    <title>Nouvelles fonctionnalités de Qt Designer 4.5</title>
    <link>http://www.shadoware.org/post/2008/10/19/Nouvelles-fonctionnalites-de-Qt-Designer-45</link>
    <guid isPermaLink="false">urn:md5:70738bd05352d99baffe0f66326567aa</guid>
    <pubDate>Sun, 19 Oct 2008 19:24:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>nokia</category><category>planet</category><category>qt</category><category>trolltech</category>    
    <description>    &lt;p&gt;Sur &lt;em&gt;&lt;del&gt;Trolltech&lt;/del&gt;Nokia Labs Blogs&lt;/em&gt;, Friedelann Kleint nous présente aujourd'hui les nouvelles fonctionnalités de Qt Designer 4.5&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/10/19/Nouvelles-fonctionnalites-de-Qt-Designer-45#pnote-610-1&quot; id=&quot;rev-pnote-610-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Au menu, on peut trouver l'ajout de filtre sur l'éditeur de propriétés ainsi que sur l'inspecteur d'objet (Ce qui peut permettre de sélectionner un composant et d'en modifier les propriétés plus rapidement).&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/qtdesigner4.5/objectinspector.png&quot; alt=&quot;objectinspector.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;objectinspector.png, oct 2008&quot; /&gt;&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/qtdesigner4.5/propertyeditorfilter.png&quot; alt=&quot;propertyeditorfilter.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;propertyeditorfilter.png, oct 2008&quot; /&gt;&lt;/p&gt;


&lt;p&gt;L'arrangement de la boite à outil est également différent&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/qtdesigner4.5/widgetbox_iconmode.png&quot; alt=&quot;widgetbox_iconmode.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;widgetbox_iconmode.png, oct 2008&quot; /&gt;&lt;/p&gt;


&lt;p&gt;De plus il est maintenant possible de&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sélectionner l'objet ancêtre d'un &lt;em&gt;widget&lt;/em&gt; en sélectionnant &lt;em&gt;Select ancestors&lt;/em&gt; du menu contextuel.&lt;/li&gt;
&lt;li&gt;Changer le &lt;em&gt;Layout&lt;/em&gt; sans casser et reconstruire le &lt;em&gt;Layout&lt;/em&gt; de la feuille&lt;/li&gt;
&lt;li&gt;Ajouter facilement une nouvelle ligne au layout (L'action &lt;em&gt;Add form layout row&lt;/em&gt; ouvrant la boite de dialogue ci-dessous)&lt;/li&gt;
&lt;li&gt;Créer des Assistants (&lt;em&gt;Wizard&lt;/em&gt;) linéaires&lt;/li&gt;
&lt;li&gt;Désactiver la traduction de certaine chaîne.&lt;/li&gt;
&lt;li&gt;...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;img src=&quot;http://www.shadoware.org/public/billets/qt/qtdesigner4.5/formlayout.png&quot; alt=&quot;formlayout.png&quot; style=&quot;display:block; margin:0 auto;&quot; title=&quot;formlayout.png, oct 2008&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Enfin, pour terminer, comme le dit Friedemann&amp;nbsp;:
&lt;q&gt;The general focus of the 4.5 release is on stability and performance.&lt;/q&gt;
Soit&amp;nbsp;: Le but principal de la version 4.5 est la stabilité et les performances.&lt;/p&gt;


&lt;p&gt;Pour plus de précision, je vous conseille d'aller voir la page d'origine et/ou de télécharger la &lt;em&gt;snapshot&lt;/em&gt;.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/10/19/Nouvelles-fonctionnalites-de-Qt-Designer-45#rev-pnote-610-1&quot; id=&quot;pnote-610-1&quot;&gt;1&lt;/a&gt;] Référence : &lt;a href=&quot;http://labs.trolltech.com/blogs/2008/10/16/new-features-of-qt-designer-45/&quot; title=&quot;http://labs.trolltech.com/blogs/2008/10/16/new-features-of-qt-designer-45/&quot;&gt;http://labs.trolltech.com/blogs/200...&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2008/10/19/Nouvelles-fonctionnalites-de-Qt-Designer-45#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2008/10/19/Nouvelles-fonctionnalites-de-Qt-Designer-45#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/610</wfw:commentRss>
      </item>
    
  <item>
    <title>QT 4.4.2 puis QT 4.4.3 sont sorties</title>
    <link>http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie</link>
    <guid isPermaLink="false">urn:md5:d8ea4848af513b7f9e2ec06ccd707535</guid>
    <pubDate>Mon, 06 Oct 2008 17:02:00 +0200</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>nokia</category><category>planet</category><category>qt</category><category>trolltech</category>    
    <description>    &lt;p&gt;En une semaine sont sortie les versions 4.4.2 et 4.4.3 de &lt;em&gt;Qt&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;La version 4.4.2 corrige de nombreux bugs (dont des fuites mémoires sur la partie &lt;em&gt;XmlPatterns&lt;/em&gt;). Vous pouvez trouver la listes des changements &lt;a href=&quot;http://www.shadoware.org/public/billets/qt/changes-4.4.2&quot;&gt;attachée&lt;/a&gt; au billet, ou dans l'archive &lt;em&gt;Qt&lt;/em&gt; se trouvant sur le site &lt;em&gt;Trolltech&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;La version 4.4.3&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie#pnote-609-1&quot; id=&quot;rev-pnote-609-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt; modifie chaque entête de fichiers, les icônes, ... pour refléter l'achat de &lt;em&gt;Trolltech&lt;/em&gt; par &lt;em&gt;Nokia&lt;/em&gt;. Par la même occasion le site de &lt;em&gt;Trolltech&lt;/em&gt; a été complètement refait (&lt;a href=&quot;http://trolltech.com&quot; hreflang=&quot;en&quot;&gt;http://trolltech.com&lt;/a&gt;).&lt;/p&gt;


&lt;p&gt;Donc si vous avez la version 4.4.2, il n'est pas nécessaire de récupérer la 4.4.3 (sauf si vous souhaiter absolument la dernière version au nom de Nokia), par contre si vous êtes encore à la version 4.4.0 ou 4.4.1, il peut être intéressant d'installer la dernière version (suivant les fonctionnalités que vous utilisez).&lt;/p&gt;


&lt;p&gt;Enfin, la question, sans réponse, est, est-ce que le site de &lt;em&gt;Trolltech&lt;/em&gt; et de &lt;em&gt;Nokia&lt;/em&gt; vont fusionner ou vont-il rester séparer&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie#pnote-609-2&quot; id=&quot;rev-pnote-609-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;&amp;nbsp;?&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie#rev-pnote-609-1&quot; id=&quot;pnote-609-1&quot;&gt;1&lt;/a&gt;] http://trolltech.com/about/news/qt-4.4.3-released&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie#rev-pnote-609-2&quot; id=&quot;pnote-609-2&quot;&gt;2&lt;/a&gt;] ce dernier est tout de même plus pratique, je trouve&lt;/p&gt;&lt;/div&gt;
</description>
    
          <enclosure url="http://www.shadoware.org/public/billets/qt/changes-4.4.2"
      length="19829" type="text/plain" />
          <enclosure url="http://www.shadoware.org/public/billets/qt/changes-4.4.3"
      length="1221" type="text/plain" />
    
    
          <comments>http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2008/09/29/QT-442-puis-QT-443-est-sortie#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/609</wfw:commentRss>
      </item>
    
  <item>
    <title>Paquet Debian et Qt</title>
    <link>http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt</link>
    <guid isPermaLink="false">urn:md5:98bc4b24cff491d05aba301c4e3acd97</guid>
    <pubDate>Mon, 08 Sep 2008 20:45:00 +0000</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Distribution</category>
        <category>debian</category><category>dépots</category><category>paquets</category><category>planet</category><category>qmake</category><category>qt</category><category>trolltech</category>    
    <description>&lt;p&gt;A titre personnel je fabrique quelques programmes en Qt. Comme j'utilise un système &lt;em&gt;Gnu/Debian&lt;/em&gt;, j'ai cherché à fabriquer des paquets pour mon système (plus pour le plaisir qu'autre chose, car la plus grande partie de mes utilisateurs sont sous &lt;em&gt;MS/Windows&lt;/em&gt;).&lt;/p&gt;


&lt;p&gt;Ce billet explique la création de paquet &lt;em&gt;Gnu/Debian&lt;/em&gt; pour des applications Qt 4 utilisant QMake&lt;/p&gt;    &lt;h3&gt;Installation des paquets&lt;/h3&gt;


&lt;p&gt;Pour la création des paquets pour des programmes utilisant &lt;code&gt;qmake&lt;/code&gt;, il faut &lt;code&gt;cdbs, dh_make, dpkg-buildpackage&lt;/code&gt;.&lt;/p&gt;

&lt;pre class=&quot;bash&quot;&gt;aptitude &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt; cdbs dh-&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; fakeroot devscripts&lt;/pre&gt;


&lt;h3&gt;Création du paquet&lt;/h3&gt;


&lt;h4&gt;Préparation&lt;/h4&gt;


&lt;p&gt;Vous pouvez donc choisir un de vos programmes que vous voulez empaqueter. Pour cela vous allez commencer par nettoyer l'arborescence de votre projet pour retirer les fichiers de sauvegarde ainsi que les fichiers de construction (&lt;code&gt;*~ *.o&lt;/code&gt;, ...). Ce petit nettoyage va permettre d'avoir un paquet source &lt;em&gt;propre&lt;/em&gt;.&lt;/p&gt;


&lt;p&gt;Il faut que vous placiez les sources dans un dossier du nom de &lt;code&gt;&amp;lt;programme&amp;gt;-&amp;lt;version&amp;gt;&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Voici un exemple de fichier projet&amp;nbsp;:&lt;/p&gt;

&lt;pre&gt;
TARGET = qgenconfig
TEMPLATE = app

CONFIG += exceptions warn_on qt
QT += xml

HEADERS += src/loadconfigimpl.h \
   src/setupfile.h \
   src/configfile.h \
   src/p_configfile.h
SOURCES += src/loadconfigimpl.cpp \
   src/setupfile.cpp \
   src/main.cpp \
   src/configfile.cpp
FORMS = ui/loadconfig.ui

DESTDIR = bin
MOC_DIR = build
OBJECTS_DIR = build
UI_DIR = build
&lt;/pre&gt;


&lt;p&gt;Pour générer le &lt;code&gt;Makefile&lt;/code&gt;, vous pouvez faire comme d'habitude&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;bash&quot;&gt;qmake-qt4 qgenconfig.pro&lt;/pre&gt;


&lt;h4&gt;Création des scripts&lt;/h4&gt;


&lt;p&gt;Pour créer les paquets, il faut un ensemble de script dans le dossier &lt;code&gt;debian&lt;/code&gt;. Pour se faciliter la vie, il est possible de créer les scripts avec &lt;code&gt;dh_make&lt;/code&gt;.&lt;/p&gt;

&lt;pre class=&quot;bash&quot;&gt;&lt;span style=&quot;color: #007800;&quot;&gt;DEBFULLNAME=&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Ulrich Van Den Hekke&amp;quot;&lt;/span&gt; dh_make -e ulrich.vdh&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;shadoware.org -n -s -c gpl&lt;/pre&gt;


&lt;p&gt;Voici la description de la liste des paramètres&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;DEBFULLNAME&lt;/code&gt; indique le nom du mainteneur.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-e&lt;/code&gt; Permet de préciser l'email (suivis de l'email).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-n&lt;/code&gt; Produit un paquet natif pour &lt;em&gt;Gnu/Debian&lt;/em&gt; (quand l'auteur fait ses paquets lui-même).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-s&lt;/code&gt; Indique que le paquet ne va contenir qu'un simple exécutable (si vous voulez faire plusieurs paquets, il suffit de ne pas mettre cette option).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-c&lt;/code&gt; Indique la licence d'utilisation (ici &lt;code&gt;gpl&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vous pouvez ensuite supprimer les fichiers exemples (mais pas nécessairement si vous voulez les étudier).&lt;/p&gt;

&lt;pre class=&quot;bash&quot;&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;rm&lt;/span&gt; debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/*&lt;/span&gt;.ex  debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/*&lt;/span&gt;.EX  debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;docs  debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;dirs&lt;/span&gt;&lt;/pre&gt;


&lt;h5&gt;Paquet simple&lt;/h5&gt;


&lt;p&gt;Nous allons commencer par créer un paquet simple. Cela signifie qu'il n'y aura qu'un seul exécutable dans le paquet (pas de librairie, ...).&lt;/p&gt;


&lt;p&gt;Dans le fichier &lt;code&gt;control&lt;/code&gt;, il faut que vous renseignez les informations du paquet que vous allez créer.&lt;/p&gt;

&lt;pre&gt;
Source: qgenconfig
Section: devel
Priority: extra
Maintainer: Ulrich Van Den Hekke &amp;lt;ulrich.vdh@shadoware.org&amp;gt;
Build-Depends: debhelper (&amp;gt;= 7)
Standards-Version: 3.7.3
Homepage: http://projects.shadoware.org/qgenconfig

Package: qgenconfig
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Description: Create a config class in Qt after loading a XML file.
 Load an XML description file of a settings object and create a class
 that can be used to load and save information in a QSettings class. To
 load information structure are used.
&lt;/pre&gt;


&lt;p&gt;Dans le paquet ci-dessus, on créait un paquet binaire et un paquet source. Les variables de dépendance (dans &lt;code&gt;Depends&lt;/code&gt;) sont remplacées automatiquement à la génération du paquet. La description est celle écrite dans &lt;code&gt;aptitude&lt;/code&gt;. La première ligne est la description courte, les suivantes (précédées d'un espace) sont la description longue.&lt;/p&gt;


&lt;p&gt;Ensuite on va remplacer le fichier &lt;code&gt;debian/rules&lt;/code&gt; en utilisant &lt;code&gt;cdbs&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#!/usr/bin/make -f&lt;/span&gt;
include &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;cdbs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;rules&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debhelper.mk
include &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;cdbs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;class&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;qmake.mk
&lt;span style=&quot;color: #007800;&quot;&gt;QMAKE=&lt;/span&gt;qmake-qt4
&amp;nbsp;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;qgenconfig::
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;DEB_DESTDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;DEB_DESTDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;qgenconfig $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;DEB_DESTDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;En premier lieu on définit les variables pour la compilation, puis ensuite on définit les opérations d'installations dans la cible &lt;code&gt;install/qgenconfig&lt;/code&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt#pnote-36-1&quot; id=&quot;rev-pnote-36-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;.
Dans les opérations, vous allez copier votre exécutable dans le dossier de génération de debian (dossier &lt;code&gt;debian/&amp;lt;cible&amp;gt;&lt;/code&gt;).&lt;/p&gt;


&lt;h5&gt;Paquet multiple&lt;/h5&gt;


&lt;p&gt;Créer plusieurs paquets à partir d'une même source avec &lt;code&gt;cdbs&lt;/code&gt; est assez simple. Il suffit de rajouter des cibles, correspondantes au fichier &lt;code&gt;control&lt;/code&gt;, dans le fichier &lt;code&gt;rules&lt;/code&gt; .&lt;/p&gt;


&lt;p&gt;Dans le fichier de &lt;code&gt;control&lt;/code&gt; on va avoir plusieurs paquets binaires pour un seul paquet source.&lt;/p&gt;

&lt;pre&gt;
Source: xinx
Section: devel
Priority: extra
Maintainer: Ulrich Van Den Hekke &amp;lt;xinx@shadoware.org&amp;gt;
Build-Depends: debhelper (&amp;gt;= 7)
Standards-Version: 3.7.3
Homepage: http://xinx.shadoware.org/

Package: xinx
Section: devel
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}, xinx-scripts (&amp;gt;= 0.7.2.0)
Recommends: xinx-plugins-services, xinx-plugins-cvs, xinx-plugins-svn
Suggests: xinx-doc
Description: XSL/JS/HTML editor for Generix
 XINX is an editor of XSL stylesheet, JavaScript, Cascading Style Sheet.
 This editor is used with egx.

Package: xinx-doc
Section: doc
Architecture: all
Depends: xinx (&amp;gt;= 0.7.2.0)
Description: Documentation for xinx
 Technical Documentation of XINX
&lt;/pre&gt;


&lt;p&gt;Nous allons définir dans le fichier &lt;code&gt;rules&lt;/code&gt; les différentes cibles que nous avons dans le fichier &lt;code&gt;control&lt;/code&gt;&lt;sup&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt#pnote-36-2&quot; id=&quot;rev-pnote-36-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;

&lt;pre class=&quot;bash&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#!/usr/bin/make -f&lt;/span&gt;
include &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;cdbs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;rules&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debhelper.mk
include &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;cdbs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;class&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;qmake.mk
&lt;span style=&quot;color: #007800;&quot;&gt;QMAKE=&lt;/span&gt;qmake-qt4 project.pro
&amp;nbsp;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx::
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinxprojectwizard&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinxprojectwizard $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;bin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
&amp;nbsp;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; -a $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libxinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libsharedxinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;*&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; -a $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;components&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;libxinxcmp&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;*&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc::
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mkdir&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;cp&lt;/span&gt; -a $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/*&lt;/span&gt; $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
	&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;rm&lt;/span&gt; -rf $&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;CURDIR&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;debian&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;xinx-doc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;html&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;.svn&lt;/pre&gt;


&lt;p&gt;Ici on génère deux paquets, le paquet binaire et la documentation.&lt;/p&gt;


&lt;h4&gt;Génération du paquet&lt;/h4&gt;


&lt;h5&gt;Mise à jour des informations du paquets&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Pour modifier le changelog sur la version courante&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;dch -a&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;Pour créer une nouvelle version&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;dch -i&lt;/pre&gt;


&lt;h5&gt;Création du paquet&lt;/h5&gt;


&lt;pre&gt;dpkg-buildpackage -rfakeroot&lt;/pre&gt;


&lt;p&gt;L'application va signer le paquet s'il trouve la clé assignée à l'utilisateur.&lt;/p&gt;


&lt;h3&gt;Création d'un dépôt&lt;/h3&gt;


&lt;p&gt;Après avoir créé des paquets, il peut-être intéressant de créer un dépôt pour installer ces paquets. voici la marche à suivre pour créer le dépôt.&lt;/p&gt;


&lt;p&gt;Sur votre serveur internet (nous ne parlerons pas ici de la mise à disposition sur Internet), vous allez devoir créer un dossier contenant votre référentiel (exemple&amp;nbsp;: &lt;code&gt;/www/sites/apt&lt;/code&gt;).&lt;/p&gt;


&lt;h4&gt;Création de l'arborescence&lt;/h4&gt;


&lt;p&gt;Vous allez devoir créer une arborescence comme suite&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;dists
   +- main 
       |- binary-i386
       |- binary-amd64
       +- source&lt;/pre&gt;


&lt;p&gt;Parmi les fichiers générés vous allez devoir mettre le fichier &lt;code&gt;.deb&lt;/code&gt; dans le dossier binaire, et les fichiers &lt;code&gt;.changes&lt;/code&gt;, &lt;code&gt;.dsc&lt;/code&gt;, et &lt;code&gt;.tar.gz&lt;/code&gt; dans le dossier &lt;code&gt;source&lt;/code&gt;.&lt;/p&gt;


&lt;h4&gt;Création d'un fichier apt-ftparchive.conf&lt;/h4&gt;


&lt;p&gt;Nous allons commencer par créer un fichier &lt;code&gt;apt-ftparchive.conf&lt;/code&gt;  dans lequel nous allons définir les fichiers à créer.&lt;/p&gt;

&lt;pre&gt;
Dir {
	ArchiveDir &amp;quot;.&amp;quot;;
	CacheDir &amp;quot;.&amp;quot;;
};

Tree &amp;quot;dists/unstable&amp;quot; {
	Sections &amp;quot;main&amp;quot;;
	Architectures &amp;quot;amd64 source&amp;quot;;
};

BinDirectory &amp;quot;dists/unstable/main/binary-amd64&amp;quot; {
	Packages &amp;quot;dists/unstable/main/binary-amd64/Packages&amp;quot;;
	Contents &amp;quot;dists/unstable/Contents-amd64&amp;quot;;
	SrcPackages &amp;quot;dists/unstable/main/source/Sources&amp;quot;;
};
&lt;/pre&gt;


&lt;h4&gt;Création du fichier apt-unstable-release.conf&lt;/h4&gt;

&lt;pre&gt;
APT::FTPArchive::Release::Origin	&amp;quot;shadoware.org&amp;quot;;
APT::FTPArchive::Release::Label		&amp;quot;shadoware.org&amp;quot;;
APT::FTPArchive::Release::Suite		&amp;quot;unstable&amp;quot;;
APT::FTPArchive::Release::Codename	&amp;quot;unstable&amp;quot;;
APT::FTPArchive::Release::Architectures	&amp;quot;amd64 source&amp;quot;;
APT::FTPArchive::Release::Components	&amp;quot;main&amp;quot;;
APT::FTPArchive::Release::Description	&amp;quot;Paquets du site Shadoware.Org&amp;quot;;
&lt;/pre&gt;


&lt;h4&gt;Création du fichier update-archive.sh&lt;/h4&gt;


&lt;p&gt;Ce fichier est celui que l'on doit exécuter pour la génération du contenu de l'arborescence&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash&quot;&gt;apt-ftparchive generate apt-ftparchive.conf
apt-ftparchive -c apt-unstable-release.conf release dists&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;unstable &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt; dists&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;unstable&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;Release&lt;/pre&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt#rev-pnote-36-1&quot; id=&quot;pnote-36-1&quot;&gt;1&lt;/a&gt;] D'autres cibles sont disponibles (cf la doc de &lt;code&gt;cdbs&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt#rev-pnote-36-2&quot; id=&quot;pnote-36-2&quot;&gt;2&lt;/a&gt;] A cause d'un bogue, ou d'une mauvaise utilisation, la variable &lt;code&gt;$(DEB_DESTDIR)&lt;/code&gt; ne me ramenait pas la bonne valeur, je l'ai donc remplacée par &lt;code&gt;$(CURDIR)/debian&lt;/code&gt;.&lt;/p&gt;&lt;/div&gt;
</description>
    
    
    
          <comments>http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2008/09/08/45-paquet-debian-et-qt#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/36</wfw:commentRss>
      </item>
    
  <item>
    <title>Mises à jour Gnu/Debian récentes</title>
    <link>http://www.shadoware.org/post/2008/02/18/43-mise-a-jours-gnu-debian-recente</link>
    <guid isPermaLink="false">urn:md5:6cfd2b9ca21c9d701f11bb6feba499d9</guid>
    <pubDate>Mon, 18 Feb 2008 18:28:00 +0000</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>Logiciels</category>
        <category>debian</category><category>planet</category><category>update</category>    
    <description>    &lt;p&gt;Bonjour,&lt;/p&gt;


&lt;p&gt;La distribution GNU/Debian propose une nouvelle mise à jour pour sa version etch. Les points importants que je remarque, sont&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;la correction de la faille sur le noyau Linux pour toutes les machines serveurs&amp;nbsp;: Veillez à bien mettre à jour votre noyau car même si vous ne proposez pas de compte aux utilisateurs, l'escalade de privilèges peut intervenir dans une faille de sécurité de votre site Internet (cf de l'injection de code).&lt;/li&gt;
&lt;li&gt;la mise à jour de KDE, qui désormais permet à Konqueror de charger le plugin flash non libre.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bien sûr, cette mise à jour propose également d'autres corrections de Bug et mise à jour de sécurité, ainsi que la suppression de certains paquets (soit trop miné/buggé, soit propriétaire). On peut par ailleurs retrouver le plugin flash dans les backports&lt;/p&gt;</description>
    
    
    
          <comments>http://www.shadoware.org/post/2008/02/18/43-mise-a-jours-gnu-debian-recente#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2008/02/18/43-mise-a-jours-gnu-debian-recente#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/34</wfw:commentRss>
      </item>
    
  <item>
    <title>Mémo Qt</title>
    <link>http://www.shadoware.org/post/2008/01/21/42-qabstractitemmodel-qt</link>
    <guid isPermaLink="false">urn:md5:53141e35fc9be789b2dcf98bfbf07cb9</guid>
    <pubDate>Mon, 21 Jan 2008 20:06:00 +0000</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>C++</category>
        <category>cmake</category><category>model</category><category>planet</category><category>qt</category>    
    <description>&lt;p&gt;Ceci est un petit mémo pour me permettre de ne pas oublier quelques astuces lors de la programmation avec Qt. En parlant de cela, je me suis commandé le livre suivant&amp;nbsp;: &lt;a href=&quot;http://www.amazon.fr/GUI-Programming-Qt4-Jasmin-Blanchette/dp/0132354160/ref=sr_11_1?ie=UTF8&amp;amp;qid=1199972515&amp;amp;sr=11-1&quot; hreflang=&quot;en&quot;&gt;C++ GUI Programming with Qt4&lt;/a&gt;.&lt;/p&gt;    &lt;h3&gt;QAbstractItemModel&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Lors de l'insertion (avec beginInsertRows()), les éléments insérés ne doivent pas contenir de sous éléments (rowCount() == 0) sous peine de causer des plantages.&lt;/li&gt;
&lt;li&gt;Un model de donnée interne, pouvant être utilisé avec QAbstractItemModel pour afficher une arborescence et étant capable de se rafraîchir à la lecture d'un fichier, se trouve dans les fichiers &lt;a href=&quot;http://xinx.shadoware.org/browser/branches/v0.7.0/libxinx/filecontentstructure.cpp&quot; hreflang=&quot;fr&quot;&gt;filecontentstructure.cpp&lt;/a&gt; et &lt;a href=&quot;http://xinx.shadoware.org/browser/branches/v0.7.0/libxinx/filecontentstructure.h&quot; hreflang=&quot;fr&quot;&gt;filecontentstructure.h&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;CMake et Qt&lt;/h3&gt;


&lt;h4&gt;Compilation d'une librairie static&lt;/h4&gt;


&lt;pre&gt;add_definitions(-DQT_SHARED)
add_library(xinxplugins STATIC ${xinxplugins_SRCS} ${xinxplugins_MOC_SRCS})&lt;/pre&gt;


&lt;h4&gt;Compilation d'un plugin&lt;/h4&gt;


&lt;h5&gt;dynamique&lt;/h5&gt;


&lt;pre&gt;add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_NO_DEBUG)
add_definitions(-DQT_SHARED)
add_library(webplugin SHARED ${webplugin_SRCS} ${webplugin_MOC_SRCS})&lt;/pre&gt;


&lt;h5&gt;static&lt;/h5&gt;


&lt;pre&gt;?&lt;/pre&gt;


&lt;h4&gt;Compilation de fichier RC pour Windows&lt;/h4&gt;


&lt;pre&gt;if(WIN32)
       add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xinx_ico.obj
               COMMAND windres.exe -I${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}/xinx_ico.obj -i${CMAKE_CURRENT_SOURCE_DIR}/${xinx_RCS}
       )
       set(xinx_RESS ${CMAKE_CURRENT_BINARY_DIR}/xinx_ico.obj)
endif(WIN32)&lt;/pre&gt;</description>
    
    
    
          <comments>http://www.shadoware.org/post/2008/01/21/42-qabstractitemmodel-qt#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/2008/01/21/42-qabstractitemmodel-qt#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/33</wfw:commentRss>
      </item>
    
  <item>
    <title>KMDAlert - Logiciel de surveillance de périphériques RAID</title>
    <link>http://www.shadoware.org/post/kmdalert</link>
    <guid isPermaLink="false">urn:md5:43e570ed02135302a4986b203b2a5081</guid>
    <pubDate>Fri, 17 Aug 2007 16:12:00 +0000</pubDate>
    <dc:creator>Ulrich Van Den Hekke</dc:creator>
        <category>KMDAlert</category>
        <category>kmdalert</category><category>mdadm</category><category>planet</category><category>raid</category>    
    <description>    &lt;h2&gt;Présentation&lt;/h2&gt;


&lt;p&gt;Possédant chez moi des disques durs en RAID logiciel &lt;em&gt;Gnu/Linux&lt;/em&gt;, j'ai toujours ressenti le besoin d'avoir une application graphique minimale pour m'avertir des changements d'états du RAID. (Par exemple un disque dur est défectueux, le RAID est dégradé, le RAID est en reconstruction). Et, par exemple, dans le cas de la reconstruction être averti à la fin de la reconstruction.&lt;/p&gt;


&lt;p&gt;KMDAlert est un petit logiciel &lt;em&gt;Gnu/Linux&lt;/em&gt; que j'ai écrit, et permettant d'afficher des informations sur les volumes RAID (gérés à l'aide du module noyau md-mod) dans la boîte à miniature (SystemTray).&lt;/p&gt;


&lt;p&gt;L'icône change suivant l'état du RAID (&lt;ins&gt;ATTENTION&amp;nbsp;: Les icônes choisies sont moches, si un graphiste veut me proposer d'autres icônes, je reste ouvert aux propositions&lt;/ins&gt;)&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;dégradé&lt;/li&gt;
&lt;li&gt;en cours de synchronisation&lt;/li&gt;
&lt;li&gt;ou tout simplement Ok.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Des messages de notifications informent aussi l'utilisateur du changement d'état d'un disque sur le RAID (par exemple le disque est en échec, supprimé, ajouté, la synchronisation démarre ou est terminée).&lt;/p&gt;


&lt;p&gt;Le logiciel est actuellement uniquement disponible en pour KDE 3. Je n'ai pas encore pris le temps de le ré-écrire. Bien que cette application a été écrite dans mon cas particulier (un RAID 1) je me suis dit qu'elle devrait fonctionner pour les autres RAIDs et intéresser d'autres personnes.&lt;/p&gt;


&lt;h2&gt;Requis&lt;/h2&gt;


&lt;p&gt;Pour fonctionner KMDAlert nécessite que le dossier &lt;code&gt;/sys&lt;/code&gt; soit monté et que &lt;code&gt;/sys/block/&lt;/code&gt; soit renseigné pour chaque volume RAID (exemple &lt;code&gt;/sys/block/md0&lt;/code&gt;, &lt;code&gt;/sys/block/md1&lt;/code&gt;, ...). &lt;code&gt;KMDAlert&lt;/code&gt; observe ensuite les modifications faites sur les fichiers pour informer l'utilisateur des modifications faites sur le volume RAID ou sur les disques le composant.&lt;/p&gt;


&lt;p&gt;L'application a été développée sur Gnu/Debian Etch donc sur un KDE 3.5 avec un noyau 2.6.18.&lt;/p&gt;


&lt;p&gt;KMDAlert ne nécessite pas de Inotify. KMDAlert lit le contenu de plusieurs fichiers dans le dossier /sys toutes les 6 secondes pour être informé de la modification de l'état du périphérique. En effet sur le noyau 2.6.18 que je possède, Inotify n'est pas averti des modifications faites sur le système de fichier /sys. Les dates de ces fichiers ne sont pas non plus modifiées. Si quelqu'un a une autre méthode à me proposer, je reste ouvert à toutes propositions.&lt;/p&gt;


&lt;p&gt;KMDAlert est une application écrite en utilisant les librairies de KDE, mais devrait tout de même fonctionner sous Gnome. Les messages de notification utilisent donc le système de notification de KDE (bien que je n'utilise pas toutes ses possibilités).&lt;/p&gt;


&lt;h2&gt;Compilation / Installation&lt;/h2&gt;


&lt;p&gt;La compilation et l'installation de KMDAlert se fait à l'aide du trio habituel&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;bash bash&quot; style=&quot;font-family:inherit&quot;&gt;.&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;configure &lt;span style=&quot;color: #660033;&quot;&gt;--prefix&lt;/span&gt;=&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;local&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; 
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;make&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;install&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;La compilation nécessite les librairies de développement KDE et Qt3, ainsi que le compilateur GCC.&lt;/p&gt;


&lt;h2&gt;Licence&lt;/h2&gt;


&lt;p&gt;La licence choisie est la  &lt;a href=&quot;http://www.gnu.org/licenses/gpl-2.0.txt&quot; hreflang=&quot;en&quot; title=&quot;GNU GENERAL PUBLIC LICENCE&quot;&gt;GNU GENERAL PUBLIC LICENSE&lt;/a&gt;&lt;/p&gt;


&lt;h2&gt;Téléchargement&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Vous pouvez télécharger une archive déjà construite de l'application sur &lt;a href=&quot;http://kde-apps.org/content/show.php/KMDAlert?content=73373&quot; hreflang=&quot;fr&quot;&gt;KDE-Apps.org&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Le dépot officiel pour télécharger les sources et participer&amp;nbsp;: &lt;a href=&quot;http://hg.shadoware.org/kmdalert?pk_campaign=shadoware&quot;&gt;http://hg.shadoware.org/kmdalert&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;Système de suivi&lt;/h2&gt;


&lt;p&gt;Il n'y a actuellement plus de système de suivi pour ce logiciel. En cas de problème, vous pouvez laisser un message dans les commentaires ou m'envoyer un mail.&lt;/p&gt;</description>
    
    
    
          <comments>http://www.shadoware.org/post/kmdalert#comment-form</comments>
      <wfw:comment>http://www.shadoware.org/post/kmdalert#comment-form</wfw:comment>
      <wfw:commentRss>http://www.shadoware.org/feed/atom/comments/24</wfw:commentRss>
      </item>
    
</channel>
</rss>
