Hi,
Another useful idea, when you’re dealing with meta-information as child in a tree view.
Usually, you can want to count your children up to a given sub-level.
This is done by changing the TreeViewItem::countSelectedItemsRecursively() method and the TreeView::getNumSelectedItems method, to add a level parameter.
The code then reads:
// juce::TreeView::getNumSelectedItems in ../../src/gui/components/controls/juce_TreeView.cpp:540
return (rootItem != 0) ? rootItem->countSelectedItemsRecursively(level) : 0;
// juce::TreeViewItem::countSelectedItemsRecursively in ../../src/gui/components/controls/juce_TreeView.cpp:1622
int TreeViewItem::countSelectedItemsRecursively(int level = -1) const throw()
{
if (level == 0) return 0;
int total = 0;
if (isSelected())
++total;
for (int i = subItems.size(); --i >= 0;)
total += subItems.getUnchecked(i)->countSelectedItemsRecursively(level - 1);
return total;
}
Similarly for the getSelectedItem method.