Is it permitted to recursively call QAbstractItemModel::beginInsertRows() ?
That is: call beginInsertRows() and then, before calling endInsertRows(), call beginInsertRows() again?

Eventually, there will be a call to endInsertRows() for every call to beginInsertRows().

The application is to pre-populate a tree with a view of a file system, including all of its sub-directories. There is also other special, proprietary information that is merged with the directory/file names.

I am attempting to do something like this:

Qt Code:
  1. void vInsertChildren( const QModelIndex & a_rtItemIndex,
  2. const QList< QFileInfo > & a_ratChildEntries )
  3. {
  4. if ( ! a_ratChildEntries.isEmpty() ) {
  5. // begin inserting children
  6. beginInsertRows( a_rtItemIndex, 0, 0 + a_ratChildEntries.count() - 1 );
  7.  
  8. // for each child ...
  9. for ( int i = 0; i <= a_ratChildEntries.count() - 1; ++ i ) {
  10. // insert child
  11. [insert row]
  12.  
  13. // check for grandchildren
  14.  
  15. QDir tGrandchildDir ( a_ratChildEntries[ i ].filePath() );
  16. QList< QFileInfo > atGrandchildEntries;
  17.  
  18. atGrandchildEntries = tGrandchildDir.entryInfoList(
  19. QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Files,
  20. QDir::Name | QDir::DirsFirst | QDir::IgnoreCase
  21. );
  22.  
  23. if ( ! atGrandchildEntries.isEmpty() ) {
  24. // insert grandchildren
  25. vInsertChildren(
  26. index( 0, 0, a_rtItemIndex ),
  27. atGrandchildEntries
  28. );
  29. }
  30.  
  31.  
  32. }
  33.  
  34. // end inserting children
  35. endInsertRows();
  36. }
  37. }
To copy to clipboard, switch view to plain text mode 

The same question applies to beginRemoveRows() / endRemoveRows().