revert: disable double-click folding/unfolding because it will cause IndexOutOfRange exception

This commit is contained in:
leo 2024-05-29 21:56:03 +08:00
parent a382a3e564
commit ea1bfad84d
6 changed files with 2 additions and 55 deletions

View file

@ -513,13 +513,6 @@ namespace SourceGit.ViewModels
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)

View file

@ -50,14 +50,7 @@
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}"
Changes="{Binding VisibleChanges}"
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"
ContextRequested="OnChangeContextRequested"
ChangeDoubleTapped="OnChangeDoubleTapped">
<v:ChangeCollectionView.Styles>
<Style Selector="TreeDataGridExpanderCell" x:DataType="vm:FileTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style>
</v:ChangeCollectionView.Styles>
</v:ChangeCollectionView>
ContextRequested="OnChangeContextRequested"/>
</Border>
</Grid>

View file

@ -1,5 +1,4 @@
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace SourceGit.Views
{
@ -24,17 +23,5 @@ namespace SourceGit.Views
e.Handled = true;
}
private void OnChangeDoubleTapped(object sender, RoutedEventArgs e)
{
if (sender is ChangeCollectionView view)
{
var selected = view.tree?.RowSelection?.SelectedItem as ViewModels.FileTreeNode;
if (selected != null && selected.IsFolder)
selected.IsExpanded = !selected.IsExpanded;
}
e.Handled = true;
}
}
}

View file

@ -105,14 +105,7 @@
ViewMode="{Binding Source={x:Static vm:Preference.Instance}, Path=CommitChangeViewMode}"
Changes="{Binding VisibleChanges}"
SelectedChanges="{Binding SelectedChanges, Mode=TwoWay}"
ContextRequested="OnChangeContextRequested"
ChangeDoubleTapped="OnChangeDoubleTapped">
<v:ChangeCollectionView.Styles>
<Style Selector="TreeDataGridExpanderCell" x:DataType="vm:FileTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style>
</v:ChangeCollectionView.Styles>
</v:ChangeCollectionView>
ContextRequested="OnChangeContextRequested"/>
</Border>
</Grid>

View file

@ -1,6 +1,5 @@
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
namespace SourceGit.Views
{
@ -22,18 +21,6 @@ namespace SourceGit.Views
e.Handled = true;
}
private void OnChangeDoubleTapped(object sender, RoutedEventArgs e)
{
if (sender is ChangeCollectionView view)
{
var selected = view.tree?.RowSelection?.SelectedItem as ViewModels.FileTreeNode;
if (selected != null && selected.IsFolder)
selected.IsExpanded = !selected.IsExpanded;
}
e.Handled = true;
}
private void OnPressedSHA(object sender, PointerPressedEventArgs e)
{
if (DataContext is ViewModels.RevisionCompare vm && sender is TextBlock block)

View file

@ -56,12 +56,6 @@
</Grid>
</DataTemplate>
</TreeDataGrid.Resources>
<TreeDataGrid.Styles>
<Style Selector="TreeDataGridExpanderCell" x:DataType="vm:FileTreeNode">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
</Style>
</TreeDataGrid.Styles>
</TreeDataGrid>
</Border>
</Grid>