Menu

Possible bug when filtering TreeListView

2018-04-04
2018-04-30
  • Dialecticus

    Dialecticus - 2018-04-04

    To filter a TreeListView I set a filter to ModelFilter property. The problem is when I set a new filter over the existing one the treeview's connecting lines are not drawn properly for the model object that is not the only visible object anymore. Here's an example using OLV demo:

    1. Go to TreeListView tab in demo. If you have three drives three root nodes are shown: C:\, D:\, and E:\ (use flash drives if needed), and they are properly connected with lines.
    2. Type D: in filter. Now only D:\ root node is shown, and no connecting lines are shown.
    3. Delete filter text. Again all three root nodes are shown, but this time connection lines are not shown in area occupied by node D:. If you expand node D:\ the problem becomes even more obvious.

    Possible solution: I believe that TreeListView should override ModelFilter, and reset IsFirstBranch and IsOnlyBranch on the first branch before applying the new filter. I do that in my workaround code:

        public static void SetModelFilter(BrightIdeasSoftware.TreeListView treeListView, BrightIdeasSoftware.IModelFilter modelFilter)
        {
            foreach (var rootNode in treeListView.FilteredObjects)
            {
                var branch = treeListView.TreeModel.GetBranch(rootNode);
                branch.IsFirstBranch = branch.IsOnlyBranch = false;
                break;
            }
    
            treeListView.ModelFilter = modelFilter;
        }
    

    Excellent library BTW. Keep it awesome.

     
  • Phillip Piper

    Phillip Piper - 2018-04-30

    Thanks for this bug report.

    I've checked in a fix to the SourceForge repo.

    If you want, check it out and see if it fixes the issue.

     

Log in to post a comment.