On Wednesday 05 May 2010 10:10:39 ext paulo wrote:
> Hi,
> 
> is it possible to turn off (possibly in the most recent ver of qtc) the 
> variable name sorting in the locals & watchers window?
> 
> I'm asking this because if I have a class like
> 
> struct Color {
>       float r, g, b, a;
> };
> 
> I would like to see them in the same sequence.
> It make my debugging work easier.

It's possible using a debugging helper, even if it's fairly obscure.

The items are sorted according to there "iname" fields, which is for
simple nested structs by default a concatenation of the member names,
with "." as separators.

The trick here would be to explicitly specify the iname as something
that's sorted the intended way, like ".0", ".1" and so on.

So in theory 

def qdump__Color(d, item):
    v = item.value
    d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"]))
    if d.isExpanded(item):
        with Children(d):
             d.putField("iname", item.iname, "0", "r")
             d.putField("iname", item.iname, "1", "g")
             d.putField("iname", item.iname, "2", "b")
             d.putField("iname", item.iname, "3", "a")

should work. In practice we run into a small bug here leading to
the "iname" field not being output and we need the following:

def qdump__Color(d, item):
    v = item.value
    d.putValue("(%s, %s, %s; %s)" % (v["r"], v["g"], v["b"], v["a"]))
    if d.isExpanded(item):
        with Children(d):
            with SubItem(d):
                d.putField("iname", item.iname + ".0")
                d.putItemHelper(Item(v["r"], item.iname, "0", "r"))
            with SubItem(d):
                d.putField("iname", item.iname + ".1")
                d.putItemHelper(Item(v["g"], item.iname, "1", "g"))
            with SubItem(d):
                d.putField("iname", item.iname + ".2")
                d.putItemHelper(Item(v["b"], item.iname, "2", "b"))
            with SubItem(d):
                d.putField("iname", item.iname + ".3")
                d.putItemHelper(Item(v["a"], item.iname, "3", "a"))

Andre'
_______________________________________________
Qt-creator mailing list
Qt-creator@trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-creator

Reply via email to