1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-07 04:10:08 +00:00

TreeViewItem::setSelected() - avoided deselecting items before re-selecting them if they're already selected.

This commit is contained in:
jules 2014-02-28 19:28:08 +00:00
parent 1f27553d38
commit 00aa1df346
2 changed files with 7 additions and 6 deletions

View file

@ -560,7 +560,7 @@ Viewport* TreeView::getViewport() const noexcept
void TreeView::clearSelectedItems()
{
if (rootItem != nullptr)
rootItem->deselectAllRecursively();
rootItem->deselectAllRecursively (nullptr);
}
int TreeView::getNumSelectedItems (int maximumDepthToSearchTo) const noexcept
@ -1299,12 +1299,13 @@ bool TreeViewItem::isSelected() const noexcept
return selected;
}
void TreeViewItem::deselectAllRecursively()
void TreeViewItem::deselectAllRecursively (TreeViewItem* itemToIgnore)
{
setSelected (false, false);
if (this != itemToIgnore)
setSelected (false, false);
for (int i = 0; i < subItems.size(); ++i)
subItems.getUnchecked(i)->deselectAllRecursively();
subItems.getUnchecked(i)->deselectAllRecursively (itemToIgnore);
}
void TreeViewItem::setSelected (const bool shouldBeSelected,
@ -1315,7 +1316,7 @@ void TreeViewItem::setSelected (const bool shouldBeSelected,
return;
if (deselectOtherItemsFirst)
getTopLevelItem()->deselectAllRecursively();
getTopLevelItem()->deselectAllRecursively (this);
if (shouldBeSelected != selected)
{

View file

@ -557,7 +557,7 @@ private:
TreeViewItem* getDeepestOpenParentItem() noexcept;
int getNumRows() const noexcept;
TreeViewItem* getItemOnRow (int index) noexcept;
void deselectAllRecursively();
void deselectAllRecursively (TreeViewItem* itemToIgnore);
int countSelectedItemsRecursively (int depth) const noexcept;
TreeViewItem* getSelectedItemWithIndex (int index) noexcept;
TreeViewItem* getNextVisibleItem (bool recurse) const noexcept;