[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] QAbstractItemView Question
From:       Matt Newell <newellm () blur ! com>
Date:       2006-11-16 21:37:32
Message-ID: 200611161337.32825.newellm () blur ! com
[Download RAW message or body]

On Thursday 16 November 2006 13:18, Brent Villalobos wrote:
> I'm a PyQt newbie so maybe there's an easier way, but I wrote my own.  I
> saved out various view attributes, swapped in a new model, and then set the
> view to those saved-out variables.  It works well and to the end user the
> table just updates without losing any context.  It's a little annoying to
> code, but I was able to save out and set selections, sort order, vertical
> positions, column size, and column positions.
>
> The problem with selections is when a new model has a different number or
> order of elements.  For example, if the first row is selected in your
> current model, then you can easily set the first row as selected when you
> reload the model.  However, the first row in the new model may be a
> completely different element.  I worked around this by designating a unique
> key for each row.  So instead of recording which rows are selected, I
> recorded which keys were selected.  Then I had to search through the new
> model and find those keys and select them in the selection model.
> -Brent
>
> > On 11/16/06, Matt Chambers <chambers@imageworks.com> wrote:
> >> Is it possible that using one of the View classes, to reset() the model,
> >> but still maintain any selections the users had on items that were in
> >> the old data, and the new data?
> >>
Why not just avoid calling reset?  If you use beginInsertRows, layoutChanged, 
or whatever is needed, then the selection will be maintained automatically.

Matt

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic