[Kde-bindings] puic QListView code generation problem

Richard Dale Richard_Dale at tipitina.demon.co.uk
Tue Sep 2 11:43:49 UTC 2003


On Monday 01 September 2003 11:58, Germain Garand wrote:
> Le Lundi 01 Septembre 2003 10:15, Richard Dale a écrit :
> > I've just been updating the rbuic for the Qt 3.2 style of uic code
> > generation - it generates a 'languageChanged()' slot where all the text
> > items of the widgets are set up.
>
> Richard, you are a machine!
> It took me monthes before I found the motivation to do it...
>
> > When the puic is updated, it might help to
>
> In fact, I did that some weeks ago, at last
Oops - I should have checked with you first about the latest code, before 
starting the rbuic with the PerlQt 3.006 version.

> > Each time it creates a new ListViewItem under ListView3, it adds it after
> > '$item'. This is the C++ version, which looks pretty similar, so I assume
> > the problem is related to declaring 'my $item' several times.
>
> It was a problem of registration of unique object names.
> See the diff for createListViewItemImpl in uic.cpp -r1.7 vs. 1.8
>
> it now looks like this:
>
> QString Uic::createListViewItemImpl( const QDomElement &e, const QString
> &parent,
>                                      const QString &parentItem )
> {
>     QString s;
>
>     QDomElement n = e.firstChild().toElement();
>
>     bool hasChildren = e.elementsByTagName( "item" ).count() > 0;
>     QString item;
>
>     if ( hasChildren ) {
>         item = "$" + registerObject( "item" );
>         s = indent + "my " + item + " = ";
>     } else {
>         item = "$item";
>         if ( item_used )
>             s = indent + item + " = ";
>         else
>             s = indent + "my " + item + " = ";
>         item_used = TRUE;
>     }
>
>     if ( !parentItem.isEmpty() )
I added a dummy registerObject(), so that 'item' variables have the same names 
as the C++:

    if ( hasChildren ) {
	item = registerObject( "item" );
	s = indent + item + " = ";
    } else {
		if (! item_used) {
			// This is here to make the ruby generated names for 'item', 
			// the same as the original C++
			item = registerObject( "item" );
			item_used = TRUE;
		}
	item = "item";
	s = indent + item + " = ";
    }

I not sure why the C++ version doesn't need that. But after that I get the 
same names coming out with ruby as for C++:

    item = Qt::ListViewItem.new(@ListView3, nil)
    item.setText(0, trUtf8("Airbrush"))
    item.setPixmap(0, @image35)
    item.setPixmap(1, @image36)
    item.setText(2, trUtf8("Standard paint tool"))

    item = Qt::ListViewItem.new(@ListView3, item)
    item.setPixmap(0, @image37)
    item.setText(1, trUtf8("Eraser"))
    item.setPixmap(1, @image36)
    item.setText(2, trUtf8("Standard paint tool"))

    @item_2 = Qt::ListViewItem.new(@ListView3, item)
    @item_2.setOpen(true)
    @item_3 = Qt::ListViewItem.new(@item_2, item)
    @item_3.setOpen(true)
    item = Qt::ListViewItem.new(@item_3, item)
    item.setText(0, trUtf8("Draft #1"))
    item.setPixmap(0, @image39)
    @item_3.setText(0, trUtf8("Local"))
    @item_2.setOpen(true)
    item = Qt::ListViewItem.new(@item_2, @item_3)
    item.setText(0, trUtf8("Server"))
    @item_2.setText(0, trUtf8("Inbox"))
    @item_2.setPixmap(0, @image38)
    @item_2.setText(1, trUtf8("143 messages"))
    @item_2.setText(2, trUtf8("(5 new)"))

> > PS: Apologies for incoherent drunk Saturday night postings on the
> > kde-perl list, and perl cluelessness - I've banned myself now! No ruby on
> > kde-perl, only here on kdebindings, as it confuses everyone (and even
> > when I'm sober maybe :) ).
>
> Oh, please, on the contrary!
> Your post about Perl vs. Ruby was simply wonderful...
> I was there, giving the manly nudge and call for emulation (which is
> absolutely not like me :), and you answered with gorgeous humor and poetry!
Oh well - maybe as long as I don't start making a habit of it, and frighten 
off the 'practical types' on kde-perl with all that beatnick style stuff :).

> [plus, your intuition is very well founded... though we say "une perle"
> (pearl),  Perl is still strongly masculine in french, as if accounting for
> the strong "macho" tendancy of its programmers :-) ]
Ah I see, I don't think of Perl as having anything to do with pearls in 
English. I certainly think ruby the language should be 'la ruby' in French 
'la belle ruby' even..

-- Richard


More information about the Kde-bindings mailing list