feature(*): supports multi-repo editing

This commit is contained in:
leo 2020-08-03 16:23:00 +08:00
parent 3c80f2700c
commit 81a3cb9566
41 changed files with 666 additions and 450 deletions

View file

@ -67,17 +67,9 @@ namespace SourceGit.UI {
InitializeComponent();
repo = opened;
repoName.Content = repo.Name;
histories.Repo = opened;
commits.Repo = opened;
if (repo.Parent != null) {
btnParent.Visibility = Visibility.Visible;
txtParent.Content = repo.Parent.Name;
} else {
btnParent.Visibility = Visibility.Collapsed;
}
UpdateBranches();
UpdateHistories();
UpdateLocalChanges();
@ -86,6 +78,17 @@ namespace SourceGit.UI {
UpdateSubmodules();
}
/// <summary>
/// Cleanup all items
/// </summary>
public void Cleanup() {
localBranchTree.ItemsSource = null;
remoteBranchTree.ItemsSource = null;
tagList.ItemsSource = null;
cachedLocalBranches.Clear();
cachedRemotes.Clear();
}
#region DATA_UPDATE
private void UpdateHistories() {
Dispatcher.Invoke(() => {
@ -244,8 +247,8 @@ namespace SourceGit.UI {
MakeBranchNode(b, remote.Children, folders, states, "remotes");
} else {
/// 对于 SUBMODULE HEAD 出于游离状态detached on commit id
/// 此时,分支既不是 本地分支,也不是远程分支
/// 对于 SUBMODULE HEAD 出于游离状态detached on commit id
/// 此时,分支既不是 本地分支,也不是远程分支
IsDetached = b.IsCurrent;
}
}
@ -297,33 +300,9 @@ namespace SourceGit.UI {
});
});
}
private void Cleanup(object sender, RoutedEventArgs e) {
localBranchTree.ItemsSource = null;
remoteBranchTree.ItemsSource = null;
tagList.ItemsSource = null;
cachedLocalBranches.Clear();
cachedRemotes.Clear();
}
#endregion
#region TOOLBAR
private void Close(object sender, RoutedEventArgs e) {
if (PopupManager.IsLocked()) return;
PopupManager.Close();
cachedLocalBranches.Clear();
cachedRemotes.Clear();
repo.Close();
}
private void GotoParent(object sender, RoutedEventArgs e) {
if (repo.Parent == null) return;
repo.Parent.Open();
e.Handled = true;
}
private void OpenFetch(object sender, RoutedEventArgs e) {
Fetch.Show(repo);
}
@ -345,7 +324,7 @@ namespace SourceGit.UI {
}
private void OpenSearch(object sender, RoutedEventArgs e) {
if (PopupManager.IsLocked()) return;
if (popupManager.IsLocked()) return;
workspace.SelectedItem = historiesSwitch;
if (histories.searchBar.Margin.Top == 0) {
@ -936,7 +915,7 @@ namespace SourceGit.UI {
}
private void UpdateSubmodule(object sender, RoutedEventArgs e) {
Waiting.Show(() => repo.UpdateSubmodule());
Waiting.Show(repo, () => repo.UpdateSubmodule());
}
private void SubmoduleLostFocus(object sender, RoutedEventArgs e) {