(In)consistent items in a QueryModel
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 ?
RE: (In)consistent items in a QueryModel - Added by Koen Deforche 12 months ago
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 ?