feature<Repository>: supports modify display name of repository

This commit is contained in:
leo 2024-01-17 11:02:08 +08:00
parent 22416812a0
commit 4e40018a78
8 changed files with 160 additions and 1 deletions

View file

@ -24,7 +24,16 @@ namespace SourceGit.Models {
public class Repository {
#region PROPERTIES_SAVED
public string Name { get; set; } = "";
public string Name {
get => name;
set {
if (name != value) {
name = value;
Watcher.NotifyDisplayNameChanged(this);
}
}
}
public string Path { get; set; } = "";
public string GitDir { get; set; } = "";
public long LastOpenTime { get; set; } = 0;
@ -131,6 +140,7 @@ namespace SourceGit.Models {
}
private readonly object updateFilterLock = new object();
private string name = string.Empty;
private int bookmark = 0;
}
}

View file

@ -14,6 +14,11 @@ namespace SourceGit.Models {
/// </summary>
public static event Action<Repository> Opened;
/// <summary>
/// 仓库的显示名变化了
/// </summary>
public static event Action<string, string> DisplayNameChanged;
/// <summary>
/// 仓库的书签变化了
/// </summary>
@ -102,6 +107,14 @@ namespace SourceGit.Models {
}
}
/// <summary>
/// 通知仓库显示名变化
/// </summary>
/// <param name="repo"></param>
public static void NotifyDisplayNameChanged(Repository repo) {
DisplayNameChanged?.Invoke(repo.Path, repo.Name);
}
/// <summary>
/// 通知仓库标签变化
/// </summary>