Started implementing proper ViewModels now that the backend is mostly done

This commit is contained in:
2025-09-26 11:02:37 +02:00
parent e2c588794e
commit 22ad11add1
4 changed files with 38 additions and 54 deletions

View File

@@ -5,10 +5,10 @@ using Gtk;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStoreShortcut>
public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStoreViewModel>
{
private readonly PreferencesGroup shortcutsGroup;
private readonly Dictionary<PasswordStoreShortcut, ActionRow> itemToRowMap = new();
private readonly Dictionary<PasswordStoreViewModel, ActionRow> itemToRowMap = new();
public PasswordStoreShortcutCollection(PreferencesGroup shortcutsGroup)
{
@@ -21,7 +21,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
switch (e.Action)
{
case NotifyCollectionChangedAction.Add:
foreach (PasswordStoreShortcut item in e.NewItems)
foreach (PasswordStoreViewModel item in e.NewItems)
{
var row = CreateShortcutRow(item);
itemToRowMap[item] = row;
@@ -33,7 +33,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
break;
case NotifyCollectionChangedAction.Remove:
foreach (PasswordStoreShortcut item in e.OldItems)
foreach (PasswordStoreViewModel item in e.OldItems)
{
if (itemToRowMap.TryGetValue(item, out var row))
{
@@ -53,7 +53,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
}
}
private ActionRow CreateShortcutRow(PasswordStoreShortcut shortcut)
private ActionRow CreateShortcutRow(PasswordStoreViewModel shortcut)
{
var row = new ActionRow();
UpdateRowFromItem(shortcut, ref row);
@@ -66,7 +66,7 @@ public class PasswordStoreShortcutCollection : ObservableCollection<PasswordStor
return row;
}
private void UpdateRowFromItem(PasswordStoreShortcut shortcut, ref ActionRow row)
private void UpdateRowFromItem(PasswordStoreViewModel shortcut, ref ActionRow row)
{
row.SetTitle(shortcut.DisplayName);
row.SetSubtitle(shortcut.Path);