Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#3250: To rebuild the tree on filter text changes, TreeView::Rebuild …
…is 1) doing too much and 2) is not present in Linux. It turns out a wxDataViewModel::Cleared() call is enough to let the attached view re-query the tree and achieve the desired effect.
  • Loading branch information
codereader committed Jan 15, 2021
1 parent 27a1de0 commit 0e20af8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 11 additions & 1 deletion libs/wxutil/dataview/ResourceTreeView.cpp
Expand Up @@ -207,7 +207,8 @@ void ResourceTreeView::SetFilterText(const wxString& filterText)

wxDataViewItem item = GetSelection();

Rebuild();
// Update the top level tree items which rebuilds the view
UpdateTreeVisibility();

// Keep the previous selection if not filtered out and is meaningful
if (item.IsOk() && _treeModelFilter->ItemIsVisible(item))
Expand All @@ -231,6 +232,15 @@ void ResourceTreeView::SetFilterText(const wxString& filterText)
}
}

void ResourceTreeView::UpdateTreeVisibility()
{
if (_treeModelFilter)
{
// Notify the attached views that it should reload
_treeModelFilter->Cleared();
}
}

void ResourceTreeView::JumpToFirstFilterMatch()
{
if (_filterText.empty()) return;
Expand Down
2 changes: 2 additions & 0 deletions libs/wxutil/dataview/ResourceTreeView.h
Expand Up @@ -153,6 +153,8 @@ class ResourceTreeView :

virtual bool IsTreeModelRowVisible(TreeModel::Row& row);

virtual void UpdateTreeVisibility();

private:
// Returns true if the given row is visible according
// to the current view mode (show favourites vs. show all)
Expand Down

0 comments on commit 0e20af8

Please sign in to comment.