diff --git a/modules/juce_gui_basics/widgets/juce_TreeView.h b/modules/juce_gui_basics/widgets/juce_TreeView.h index 5e75046666..7c6a466029 100644 --- a/modules/juce_gui_basics/widgets/juce_TreeView.h +++ b/modules/juce_gui_basics/widgets/juce_TreeView.h @@ -83,6 +83,20 @@ public: */ void addSubItem (TreeViewItem* newItem, int insertPosition = -1); + /** Adds a sub-item with a sort-comparator, assuming that the existing items are already sorted. + + @param comparator the comparator object for sorting - see sortSubItems() for details about + the methods this class must provide. + @param newItem the object to add to the item's sub-item list. Once added, these can be + found using getSubItem(). When the items are later removed with + removeSubItem() (or when this item is deleted), they will be deleted. + */ + template + void addSubItemSorted (ElementComparator& comparator, TreeViewItem* newItem) + { + addSubItem (newItem, findInsertIndexInSortedArray (comparator, subItems.begin(), newItem, 0, subItems.size())); + } + /** Removes one of the sub-items. @param index the item to remove @@ -519,7 +533,7 @@ private: //============================================================================== TreeView* ownerView; TreeViewItem* parentItem; - OwnedArray subItems; + OwnedArray subItems; int y, itemHeight, totalHeight, itemWidth, totalWidth; int uid; bool selected : 1;