Reviewing merge request #2262: Ensure complete mappings are created for first children of parent QModelIndexes

This commit is for creating mappings properly in QSortFilterProxyModel when creating new rows in a parent QModelIndex which did not have any child items before.

Without it QSFPM does not have complete mappings and returns an invalid QModelIndex when it should not sometimes.

Commits that would be merged:

Version 5
  • Version 1
  • Version 2
  • Version 3
  • Version 4
  • Version 5
  • 0a4f8a7
  • 6c3fa69
  • Make sure mappings are created for columns when indexes newly become parents.

Showing 0a4f8a7-6c3fa69

Comments

Wouldn’t it be better to just call create_mapping or something similair, and return ?

Not really. There’s already a mapping for source_parent, which means create_mapping would be an early return.

We could do this:

beginInsertRows(proxy_parent, 0, proxy_rows);
remove_from_mapping(source_parent);
create_mapping(source_parent)
endInsertRows();
return;

But then we'd need to loop and do filterAcceptsRow to calculate proxy_rows, and then do the same loop again in create_mapping.

We could build the in source_rows for the Mapping in source_items_inserted and pass it as an optional argument to create_mapping, but I'm not sure that’s a better solution.

→ State changed from New to Revise and resubmit

Please put the test in the QSortFilterProxy model test.
Also remove the qDebug()

And the Qt coding style put the { on the same line as the if.

→ State changed from Revise and resubmit to Merged

Merged into oslo-staging-2
315c09c3873f7c5d8b785443372bf975bae47ee7

Add a new comment:

Login or create an account to post a comment

How to apply this merge request to your repository