[Qt-interest] Issues with QModelTest
Scott Aron Bloom
Scott.Bloom at onshorecs.com
Mon Mar 14 19:32:06 CET 2011
Im using the latest qmodeltest, from the KDE area.. (Don't have the URL
handy)
But I had this problem with the latest one put out directly by the
Trolls as well..
Here is my problem...
I have a model, that is a lazy load (using the canFetchMore/fetchMore
mechanism).
Normally not a problem except, this model is normally represented by a
tree.
Similar to the QDirModel system.
The issue is, the children of a node, are only loaded when the node is
expanded.. However, a dummy child count is used so the "+" is always
show. If there no actual children, the plus goes away on expansion
Here is the problem.. the "fetchMore" function, does something like this
beginRemoveRows( parent, 0, 0 );
removeDummyChild();
endRemoveRows();
int realChildCount = getRealChildCOunt();
if ( !realChildCount )
return;
beginInsertRows( parent, 0, realChildCount - 1 );
loadRealchildren();
endInsertRows();
the problem is the model test code, does something like this to test the
boundary cases.
On the remove (and insert), it gets the last before the remove, and the
first item after, and checks they are in the right spot after the
removal..
The problem is, the index() calls, do a load of the children.. Which
means (loadRealChildren does nothing).. the boundary is changing by
getting the index! What used to be a single dummy child, will actually
have multiple children, or none...
The solution I usually do, is simply disconnect the test for insert and
begin remove, but then I have missed "real" problems in my insert and
remove
Any thoughts on this??
Scott
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110314/33e615da/attachment.html
More information about the Qt-interest-old
mailing list