mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-26 21:04:59 +00:00
enhance: allow drag-drop of item (or folder) anywhere in repo-list (#1459)
Dropping on a non-Group item was not allowed earlier, but now it adds/moves the dragged item into the parent Group (possibly Root) of the drop-target item.
This commit is contained in:
parent
d192712f51
commit
743be5491a
2 changed files with 24 additions and 2 deletions
|
@ -173,6 +173,25 @@ namespace SourceGit.ViewModels
|
|||
activePage.Popup = new CreateGroup(null);
|
||||
}
|
||||
|
||||
public RepositoryNode FindParentGroup(RepositoryNode node, RepositoryNode group = null)
|
||||
{
|
||||
var collection = (group == null) ? Preferences.Instance.RepositoryNodes : group.SubNodes;
|
||||
if (collection.Contains(node))
|
||||
return group;
|
||||
|
||||
foreach (var item in collection)
|
||||
{
|
||||
if (!item.IsRepository)
|
||||
{
|
||||
var parent = FindParentGroup(node, item);
|
||||
if (parent != null)
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void MoveNode(RepositoryNode from, RepositoryNode to)
|
||||
{
|
||||
Preferences.Instance.MoveNode(from, to, true);
|
||||
|
|
|
@ -215,7 +215,7 @@ namespace SourceGit.Views
|
|||
if (to == null)
|
||||
return;
|
||||
|
||||
e.DragEffects = to.IsRepository ? DragDropEffects.None : DragDropEffects.Move;
|
||||
e.DragEffects = DragDropEffects.Move;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
@ -226,12 +226,15 @@ namespace SourceGit.Views
|
|||
return;
|
||||
|
||||
var to = grid.DataContext as ViewModels.RepositoryNode;
|
||||
if (to == null || to.IsRepository)
|
||||
if (to == null)
|
||||
{
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (to.IsRepository)
|
||||
to = ViewModels.Welcome.Instance.FindParentGroup(to);
|
||||
|
||||
if (e.Data.Contains("MovedRepositoryTreeNode") &&
|
||||
e.Data.Get("MovedRepositoryTreeNode") is ViewModels.RepositoryNode moved)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue