(In)consistent items in a QueryModel
Added by Benoit FANCHON 12 months ago
Consider a QueryModel displayed in a WTableView, where the Query imposes some restriction. Example : where ("value" > 42).
Add new valid items with Session::add(new Item(51)) doesn't add them to the QueryModel.
When the query is reloaded (scrolling a WTableView), the new items will be found but the model size hasn't been updated.
So the WTableView won't display all items.
Now add items with QueryTable::insertRows() : the size of the model is updated correctly and new rows are displayed in the WTableView.
But if the items shouldn't be displayed (new Items with a value of 0), reloading the query (scrolling the WTableView) will erase them without updating the model's size.
Thus you get a "geometry inconsistent with database" exception.
Same problem arise if you allow editing the content of the queryModel throught a WTableView. You can have items disappearing without updating the model's size.
How did you intend insertion with non-trivial queries ?
Replies (1)
RE: (In)consistent items in a QueryModel - Added by Koen Deforche 12 months ago
Hey Benoit,
Out-of-the box, the QueryModel write features (insertRows(), setData()) are intended only to be used with plaint-table views, or at least with queries without restrictions. I'm not sure if there is a sensible approach to handle the situation you describe there: it seems that it is bad user interface practice (at least) to not show the data that a user has just inserted.
For anything more complicated, you need to define a strategy of what you would want the behavior to be in the first place ?
Regards,
koen
(1-1/1)