mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-27 21:27:19 -08:00
Compare commits
No commits in common. "8e31ea9140bcd831951c722885b6ff49a6d9cc30" and "85b83990a80936138ba07697edde8580e1960a4c" have entirely different histories.
8e31ea9140
...
85b83990a8
6 changed files with 21 additions and 60 deletions
|
@ -15,15 +15,10 @@ namespace SourceGit.ViewModels
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
public object Backend { get; private set; } = null;
|
public object Backend { get; private set; } = null;
|
||||||
public int Depth { get; set; } = 0;
|
public int Depth { get; set; } = 0;
|
||||||
|
public bool IsFiltered { get; set; } = false;
|
||||||
public bool IsSelected { get; set; } = false;
|
public bool IsSelected { get; set; } = false;
|
||||||
public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>();
|
public List<BranchTreeNode> Children { get; private set; } = new List<BranchTreeNode>();
|
||||||
|
|
||||||
public bool IsFiltered
|
|
||||||
{
|
|
||||||
get => _isFiltered;
|
|
||||||
set => SetProperty(ref _isFiltered, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsExpanded
|
public bool IsExpanded
|
||||||
{
|
{
|
||||||
get => _isExpanded;
|
get => _isExpanded;
|
||||||
|
@ -51,7 +46,6 @@ namespace SourceGit.ViewModels
|
||||||
get => Backend is Models.Branch b ? b.FriendlyName : null;
|
get => Backend is Models.Branch b ? b.FriendlyName : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _isFiltered = false;
|
|
||||||
private bool _isExpanded = false;
|
private bool _isExpanded = false;
|
||||||
private CornerRadius _cornerRadius = new CornerRadius(4);
|
private CornerRadius _cornerRadius = new CornerRadius(4);
|
||||||
|
|
||||||
|
|
|
@ -643,12 +643,10 @@ namespace SourceGit.ViewModels
|
||||||
NavigateToCommit(_currentBranch.Head);
|
NavigateToCommit(_currentBranch.Head);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateFilters(List<string> filters, bool toggle)
|
public void UpdateFilter(string filter, bool toggle)
|
||||||
{
|
{
|
||||||
var changed = false;
|
var changed = false;
|
||||||
if (toggle)
|
if (toggle)
|
||||||
{
|
|
||||||
foreach (var filter in filters)
|
|
||||||
{
|
{
|
||||||
if (!_settings.Filters.Contains(filter))
|
if (!_settings.Filters.Contains(filter))
|
||||||
{
|
{
|
||||||
|
@ -656,11 +654,9 @@ namespace SourceGit.ViewModels
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var filter in filters)
|
changed = _settings.Filters.Remove(filter);
|
||||||
changed |= _settings.Filters.Remove(filter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
|
|
|
@ -72,9 +72,9 @@
|
||||||
Classes="filter"
|
Classes="filter"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
|
IsCheckedChanged="OnToggleFilter"
|
||||||
IsVisible="{Binding IsBranch}"
|
IsVisible="{Binding IsBranch}"
|
||||||
IsChecked="{Binding IsFiltered}"
|
IsChecked="{Binding IsFiltered}"
|
||||||
Click="OnToggleFilterClicked"
|
|
||||||
ToolTip.Tip="{DynamicResource Text.Filter}"/>
|
ToolTip.Tip="{DynamicResource Text.Filter}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -428,23 +428,12 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnToggleFilterClicked(object sender, RoutedEventArgs e)
|
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.Repository repo &&
|
if (sender is ToggleButton toggle && DataContext is ViewModels.Repository repo)
|
||||||
sender is ToggleButton toggle &&
|
|
||||||
toggle.DataContext is ViewModels.BranchTreeNode { Backend: Models.Branch branch } node)
|
|
||||||
{
|
{
|
||||||
bool filtered = toggle.IsChecked == true;
|
if (toggle.DataContext is ViewModels.BranchTreeNode { Backend: Models.Branch branch })
|
||||||
List<string> filters = [branch.FullName];
|
repo.UpdateFilter(branch.FullName, toggle.IsChecked == true);
|
||||||
if (branch.IsLocal && !string.IsNullOrEmpty(branch.Upstream))
|
|
||||||
{
|
|
||||||
filters.Add(branch.Upstream);
|
|
||||||
|
|
||||||
node.IsFiltered = filtered;
|
|
||||||
UpdateUpstreamFilterState(repo.RemoteBranchTrees, branch.Upstream, filtered);
|
|
||||||
}
|
|
||||||
|
|
||||||
repo.UpdateFilters(filters, filtered);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
@ -477,23 +466,6 @@ namespace SourceGit.Views
|
||||||
CollectBranchesInNode(outs, sub);
|
CollectBranchesInNode(outs, sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateUpstreamFilterState(List<ViewModels.BranchTreeNode> collection, string upstream, bool isFiltered)
|
|
||||||
{
|
|
||||||
foreach (var node in collection)
|
|
||||||
{
|
|
||||||
if (node.Backend is Models.Branch b && b.FullName == upstream)
|
|
||||||
{
|
|
||||||
node.IsFiltered = isFiltered;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (node.Backend is Models.Remote r && upstream.StartsWith($"refs/remotes/{r.Name}/", StringComparison.Ordinal))
|
|
||||||
return UpdateUpstreamFilterState(node.Children, upstream, isFiltered);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool _disableSelectionChangingEvent = false;
|
private bool _disableSelectionChangingEvent = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,8 @@
|
||||||
Classes="filter"
|
Classes="filter"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
Click="OnToggleFilterClicked"
|
IsCheckedChanged="OnToggleFilter"
|
||||||
IsChecked="{Binding IsFiltered, Mode=TwoWay}"
|
IsChecked="{Binding IsFiltered}"
|
||||||
IsVisible="{Binding !IsFolder}"
|
|
||||||
ToolTip.Tip="{DynamicResource Text.Filter}"/>
|
ToolTip.Tip="{DynamicResource Text.Filter}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
@ -79,8 +78,8 @@
|
||||||
Classes="filter"
|
Classes="filter"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
Click="OnToggleFilterClicked"
|
IsCheckedChanged="OnToggleFilter"
|
||||||
IsChecked="{Binding IsFiltered, Mode=TwoWay}"
|
IsChecked="{Binding IsFiltered}"
|
||||||
ToolTip.Tip="{DynamicResource Text.Filter}"/>
|
ToolTip.Tip="{DynamicResource Text.Filter}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
|
|
@ -247,7 +247,7 @@ namespace SourceGit.Views
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnToggleFilterClicked(object sender, RoutedEventArgs e)
|
private void OnToggleFilter(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is ToggleButton toggle && DataContext is ViewModels.Repository repo)
|
if (sender is ToggleButton toggle && DataContext is ViewModels.Repository repo)
|
||||||
{
|
{
|
||||||
|
@ -258,7 +258,7 @@ namespace SourceGit.Views
|
||||||
target = tag;
|
target = tag;
|
||||||
|
|
||||||
if (target != null)
|
if (target != null)
|
||||||
repo.UpdateFilters([target.Name], toggle.IsChecked == true);
|
repo.UpdateFilter(target.Name, toggle.IsChecked == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
|
Loading…
Reference in a new issue