feature: double-click on single-selecte change tree or file tree will expand/collapse folder node

This commit is contained in:
leo 2024-05-29 20:48:51 +08:00
parent cce4e5348c
commit 9d13b17aaf
8 changed files with 70 additions and 12 deletions

View file

@ -511,14 +511,22 @@ namespace SourceGit.ViewModels
}
};
source.Selection = new Models.TreeDataGridSelectionModel<FileTreeNode>(source, x => x.Children);
source.RowSelection.SingleSelect = true;
source.RowSelection.SelectionChanged += (s, _) =>
var selection = new Models.TreeDataGridSelectionModel<FileTreeNode>(source, x => x.Children);
selection.SingleSelect = true;
selection.RowDoubleTapped += (s, e) =>
{
var model = s as Models.TreeDataGridSelectionModel<FileTreeNode>;
var node = model.SelectedItem;
if (node != null && node.IsFolder)
node.IsExpanded = !node.IsExpanded;
};
selection.SelectionChanged += (s, _) =>
{
if (s is Models.TreeDataGridSelectionModel<FileTreeNode> selection)
RefreshViewRevisionFile(selection.SelectedItem?.Backend as Models.Object);
};
source.Selection = selection;
RevisionFiles = source;
}