If I understand correctly, you mean a way to store indexes in internalPointer of WModelIndex? This is a good way to restore the selection position when sorting or any other events emitting layoutChanged. But, I mean another operation - retrieving data from the database using cache (like Dbo QueryModel). layoutChanged not emits when WTableView causes data(...) method of model, although in reality the data may already changed since the last cache. If the db table data changes, the position of the selection will remain, but it will be another database row.
Regards, Aleksey 2010/9/29 Koen Deforche <[email protected]>: > 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 > ------------------------------------------------------------------------------ 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
