(GUI): improved selection by mask performance on large directories.

This commit is contained in:
morkt
2017-01-12 11:14:05 +04:00
parent 713417be87
commit 89b7d2cfd3
2 changed files with 10 additions and 9 deletions

View File

@@ -44,6 +44,11 @@ namespace GARbro.GUI
{ {
} }
new public bool SetSelectedItems (IEnumerable selected_items)
{
return base.SetSelectedItems (selected_items);
}
protected override DependencyObject GetContainerForItemOverride() protected override DependencyObject GetContainerForItemOverride()
{ {
return new ListViewItemEx(); return new ListViewItemEx();

View File

@@ -1169,6 +1169,7 @@ namespace GARbro.GUI
CurrentDirectory.SelectAll(); CurrentDirectory.SelectAll();
return; return;
} }
SetBusyState();
var glob = new FileNameGlob (selection.Mask.Text); var glob = new FileNameGlob (selection.Mask.Text);
var matching = ViewModel.Where (entry => glob.IsMatch (entry.Name)); var matching = ViewModel.Where (entry => glob.IsMatch (entry.Name));
if (!matching.Any()) if (!matching.Any())
@@ -1176,15 +1177,10 @@ namespace GARbro.GUI
SetStatusText (string.Format (guiStrings.MsgNoMatching, selection.Mask.Text)); SetStatusText (string.Format (guiStrings.MsgNoMatching, selection.Mask.Text));
return; return;
} }
int count = 0; var selected = CurrentDirectory.SelectedItems.Cast<EntryViewModel>();
foreach (var item in matching) matching = matching.Except (selected).ToList();
{ int count = matching.Count();
if (!CurrentDirectory.SelectedItems.Contains (item)) CurrentDirectory.SetSelectedItems (selected.Concat (matching));
{
CurrentDirectory.SelectedItems.Add (item);
++count;
}
}
if (count != 0) if (count != 0)
SetStatusText (Localization.Format ("MsgSelectedFiles", count)); SetStatusText (Localization.Format ("MsgSelectedFiles", count));
} }