mirror of
https://github.com/wismna/ModernKeePass.git
synced 2025-10-03 15:40:18 -04:00
Search box now recursively search sub groups
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -20,7 +21,22 @@ namespace ModernKeePass.ViewModels
|
|||||||
public ObservableCollection<EntryVm> Entries
|
public ObservableCollection<EntryVm> Entries
|
||||||
{
|
{
|
||||||
get { return _entries; }
|
get { return _entries; }
|
||||||
set { SetProperty(ref _entries, value); }
|
private set { SetProperty(ref _entries, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<EntryVm> SubEntries
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var subEntries = new List<EntryVm>();
|
||||||
|
subEntries.AddRange(Entries);
|
||||||
|
foreach (var group in Groups)
|
||||||
|
{
|
||||||
|
subEntries.AddRange(group.SubEntries);
|
||||||
|
}
|
||||||
|
|
||||||
|
return subEntries;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObservableCollection<GroupVm> Groups { get; set; } = new ObservableCollection<GroupVm>();
|
public ObservableCollection<GroupVm> Groups { get; set; } = new ObservableCollection<GroupVm>();
|
||||||
@@ -28,8 +44,7 @@ namespace ModernKeePass.ViewModels
|
|||||||
public PwUuid IdUuid => _pwGroup?.Uuid;
|
public PwUuid IdUuid => _pwGroup?.Uuid;
|
||||||
public string Id => IdUuid?.ToHexString();
|
public string Id => IdUuid?.ToHexString();
|
||||||
public bool IsNotRoot => ParentGroup != null;
|
public bool IsNotRoot => ParentGroup != null;
|
||||||
|
|
||||||
|
|
||||||
public bool ShowRestore => IsNotRoot && ParentGroup.IsSelected;
|
public bool ShowRestore => IsNotRoot && ParentGroup.IsSelected;
|
||||||
|
|
||||||
public bool IsRecycleOnDelete => _database.RecycleBinEnabled && !IsSelected && !ParentGroup.IsSelected;
|
public bool IsRecycleOnDelete => _database.RecycleBinEnabled && !IsSelected && !ParentGroup.IsSelected;
|
||||||
|
@@ -156,7 +156,7 @@ namespace ModernKeePass.Views
|
|||||||
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
|
private void SearchBox_OnSuggestionsRequested(SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
|
||||||
{
|
{
|
||||||
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx://Assets/ModernKeePass-SmallLogo.scale-80.png"));
|
var imageUri = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx://Assets/ModernKeePass-SmallLogo.scale-80.png"));
|
||||||
var results = Model.Entries.Where(e => e.Name.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
|
var results = Model.SubEntries.Where(e => e.Name.IndexOf(args.QueryText, StringComparison.OrdinalIgnoreCase) >= 0).Take(5);
|
||||||
foreach (var result in results)
|
foreach (var result in results)
|
||||||
{
|
{
|
||||||
args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Name, result.ParentGroup.Name, result.Id, imageUri, string.Empty);
|
args.Request.SearchSuggestionCollection.AppendResultSuggestion(result.Name, result.ParentGroup.Name, result.Id, imageUri, string.Empty);
|
||||||
|
Reference in New Issue
Block a user