mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature<WorkingCopy>: fold tree nodes by default if there are more than 50 local changes
This commit is contained in:
parent
bd868dd780
commit
f628cce1fe
1 changed files with 11 additions and 8 deletions
|
@ -26,7 +26,7 @@ namespace SourceGit.UI {
|
||||||
public string FilePath { get; set; } = "";
|
public string FilePath { get; set; } = "";
|
||||||
public string Name { get; set; } = "";
|
public string Name { get; set; } = "";
|
||||||
public bool IsFile { get; set; } = false;
|
public bool IsFile { get; set; } = false;
|
||||||
public bool IsNodeExpanded { get; set; } = true;
|
public bool IsNodeExpanded { get; set; } = false;
|
||||||
public Git.Change Change { get; set; } = null;
|
public Git.Change Change { get; set; } = null;
|
||||||
public ObservableCollection<Node> Children { get; set; } = new ObservableCollection<Node>();
|
public ObservableCollection<Node> Children { get; set; } = new ObservableCollection<Node>();
|
||||||
}
|
}
|
||||||
|
@ -153,6 +153,8 @@ namespace SourceGit.UI {
|
||||||
RemoveTreeNode(tree, exist);
|
RemoveTreeNode(tree, exist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var isDefaultExpand = changes.Count <= 50;
|
||||||
|
|
||||||
foreach (var c in changes) {
|
foreach (var c in changes) {
|
||||||
if (list.FirstOrDefault(one => one.Path == c.Path) != null) continue;
|
if (list.FirstOrDefault(one => one.Path == c.Path) != null) continue;
|
||||||
|
|
||||||
|
@ -166,7 +168,7 @@ namespace SourceGit.UI {
|
||||||
}
|
}
|
||||||
if (!added) list.Add(c);
|
if (!added) list.Add(c);
|
||||||
|
|
||||||
InsertTreeNode(tree, c);
|
InsertTreeNode(tree, c, isDefaultExpand);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,12 +1057,13 @@ namespace SourceGit.UI {
|
||||||
Helpers.TreeViewHelper.SelectWholeTree(tree);
|
Helpers.TreeViewHelper.SelectWholeTree(tree);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Node InsertTreeNode(ObservableCollection<Node> nodes, string name, string path, bool isFile = false, Git.Change change = null) {
|
private Node InsertTreeNode(ObservableCollection<Node> nodes, string name, string path, bool isFile, Git.Change change, bool expand) {
|
||||||
Node node = new Node();
|
Node node = new Node();
|
||||||
node.Name = name;
|
node.Name = name;
|
||||||
node.FilePath = path;
|
node.FilePath = path;
|
||||||
node.IsFile = isFile;
|
node.IsFile = isFile;
|
||||||
node.Change = change;
|
node.Change = change;
|
||||||
|
node.IsNodeExpanded = expand;
|
||||||
|
|
||||||
bool isAdded = false;
|
bool isAdded = false;
|
||||||
if (node.IsFile) {
|
if (node.IsFile) {
|
||||||
|
@ -1087,21 +1090,21 @@ namespace SourceGit.UI {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InsertTreeNode(ObservableCollection<Node> nodes, Git.Change change) {
|
private void InsertTreeNode(ObservableCollection<Node> nodes, Git.Change change, bool expand) {
|
||||||
string[] subs = change.Path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries);
|
string[] subs = change.Path.Split(new char[] { '\\', '/' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (subs.Length == 1) {
|
if (subs.Length == 1) {
|
||||||
InsertTreeNode(nodes, change.Path, change.Path, true, change);
|
InsertTreeNode(nodes, change.Path, change.Path, true, change, false);
|
||||||
} else {
|
} else {
|
||||||
Node last = nodes.FirstOrDefault(o => o.Name == subs[0]);
|
Node last = nodes.FirstOrDefault(o => o.Name == subs[0]);
|
||||||
if (last == null) last = InsertTreeNode(nodes, subs[0], subs[0]);
|
if (last == null) last = InsertTreeNode(nodes, subs[0], subs[0], false, null, expand);
|
||||||
|
|
||||||
for (int i = 1; i < subs.Length - 1; i++) {
|
for (int i = 1; i < subs.Length - 1; i++) {
|
||||||
var p = last.Children.FirstOrDefault(o => o.Name == subs[i]);
|
var p = last.Children.FirstOrDefault(o => o.Name == subs[i]);
|
||||||
if (p == null) p = InsertTreeNode(last.Children, subs[i], last.FilePath + "/" + subs[i]);
|
if (p == null) p = InsertTreeNode(last.Children, subs[i], last.FilePath + "/" + subs[i], false, null, expand);
|
||||||
last = p;
|
last = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertTreeNode(last.Children, subs[subs.Length - 1], change.Path, true, change);
|
InsertTreeNode(last.Children, subs[subs.Length - 1], change.Path, true, change, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue