nodeeditor icon indicating copy to clipboard operation
nodeeditor copied to clipboard

Allow arbitrary ordering of nodes in the context menu

Open Quincunx271 opened this issue 6 years ago • 0 comments

The ordering of nodes inside the DataModelRegistry is currently pretty arbitrary. When you open the context menu, the nodes are ordered by Category (sorted, as it uses std::set), but within each category, there is no ordering. If I understand the code correctly, this is because RegisteredModelsCategoryMap is a std::unordered_map.

I think it's beneficial to allow this ordering to be fully specified by a user of this library, or at least the order of nodes within any given category.

My proposal is thus the following:

  • Keep the models of a given category in the order that they were registered. This is backwards compatible, assuming the user doesn't rely on the iteration order of unordered_map
  • Keep the categories in the order that they are inserted in via registerModel. Basically, use a std::vector instead of a std::set. It might be a good idea to add a sortCategories() function. This is backwards incompatible, but I think it's valuable. If we want to stay backwards compatible, there should at least be a way to specify the order of the categories.

Quincunx271 avatar Mar 27 '18 22:03 Quincunx271