Hey Aleksey,

2010/9/29 Aleksey Chirkin <[email protected]>:
> Hi!
>
> I have implemented its own model based of WAbstractItemModel, which
> takes data from database (like Dbo QueryModel).
> I set it model to WTableView.
>
> For example, my table have 1000 rows. My model implemented with the
> use of the cache, as well as the Dbo QueryModel.
> When I select first row in table and then scroll down, selection is
> still remain - it is good until the table is not changed (even a
> change the number of rows in the table shifts selected position).
>
> What do you think about this? I thought a lot of options to solve this
> problem. The ideal solution - change the comparison of indexes to
> other criteria (such as primary key), but to achieve this I need to
> extend WModelIndex (operator==()) or WItemSelectionModel (isSelected
> method).

Your custom model should implement the toRawIndex() and fromRawIndex()
methods. These methods are used by views to keep track of model
indexes while the model changes its layout, is sorted, or likewise. In
this case it sounds like you could use the primary key value as a raw
index representation.

Regards,
koen

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to