Refilter on search update
This commit is contained in:
parent
6d7b3bd5f0
commit
28802c8279
@ -43,28 +43,18 @@ namespace ApplicationServices
|
||||
else
|
||||
{
|
||||
foreach (var book in books)
|
||||
UpdateUserDefinedItems(book);
|
||||
}
|
||||
}
|
||||
|
||||
public static void FullReIndex() => performSafeCommand(fullReIndex);
|
||||
|
||||
internal static void UpdateUserDefinedItems(Book book) => performSafeCommand(e =>
|
||||
{
|
||||
UpdateLiberatedStatus(book);
|
||||
UpdateBookTags(book);
|
||||
UpdateUserRatings(book);
|
||||
e.UpdateLiberatedStatus(book);
|
||||
e.UpdateTags(book.AudibleProductId, book.UserDefinedItem.Tags);
|
||||
e.UpdateUserRatings(book);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void FullReIndex() => performSafeCommand(e =>
|
||||
fullReIndex(e)
|
||||
);
|
||||
|
||||
internal static void UpdateLiberatedStatus(Book book) => performSafeCommand(e =>
|
||||
e.UpdateLiberatedStatus(book)
|
||||
);
|
||||
|
||||
internal static void UpdateBookTags(Book book) => performSafeCommand(e =>
|
||||
e.UpdateTags(book.AudibleProductId, book.UserDefinedItem.Tags)
|
||||
);
|
||||
|
||||
internal static void UpdateUserRatings(Book book) => performSafeCommand(e =>
|
||||
e.UpdateUserRatings(book)
|
||||
);
|
||||
|
||||
private static void performSafeCommand(Action<SearchEngine> action)
|
||||
@ -92,7 +82,6 @@ namespace ApplicationServices
|
||||
isUpdating = true;
|
||||
|
||||
action(new SearchEngine());
|
||||
|
||||
if (!prevIsUpdating)
|
||||
SearchEngineUpdated?.Invoke(null, null);
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ namespace LibationAvalonia.Controls
|
||||
IsEnabled = false
|
||||
};
|
||||
|
||||
if (ToolTip.GetTip(cell) is null)
|
||||
ToolTip.SetTip(cell, "Click to change ratings");
|
||||
|
||||
if (Binding != null)
|
||||
|
||||
@ -41,6 +41,7 @@ namespace LibationAvalonia.ViewModels
|
||||
|
||||
public ProductsDisplayViewModel()
|
||||
{
|
||||
SearchEngineCommands.SearchEngineUpdated += SearchEngineCommands_SearchEngineUpdated;
|
||||
GridEntries = new(SOURCE);
|
||||
GridEntries.Filter = CollectionFilter;
|
||||
|
||||
@ -166,6 +167,18 @@ namespace LibationAvalonia.ViewModels
|
||||
return booksFilteredIn.Concat(seriesFilteredIn).ToList();
|
||||
}
|
||||
|
||||
private async void SearchEngineCommands_SearchEngineUpdated(object sender, EventArgs e)
|
||||
{
|
||||
var filterResults = QueryResults(SOURCE, FilterString);
|
||||
|
||||
if (filterResults.Except(FilteredInGridEntries).Any())
|
||||
{
|
||||
FilteredInGridEntries = filterResults;
|
||||
GridEntries.CommitEdit();
|
||||
await Dispatcher.UIThread.InvokeAsync(GridEntries.Refresh);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Scan and Remove Books
|
||||
|
||||
@ -262,7 +262,7 @@ namespace LibationSearchEngine
|
||||
{
|
||||
// fields are key value pairs. MULTIPLE FIELDS CAN POTENTIALLY HAVE THE SAME KEY.
|
||||
// ie: must remove old before adding new else will create unwanted duplicates.
|
||||
d.RemoveField(fieldName);
|
||||
d.RemoveField(fieldName.ToLower());
|
||||
d.AddAnalyzed(fieldName, newValue);
|
||||
});
|
||||
|
||||
@ -279,13 +279,13 @@ namespace LibationSearchEngine
|
||||
// fields are key value pairs. MULTIPLE FIELDS CAN POTENTIALLY HAVE THE SAME KEY.
|
||||
// ie: must remove old before adding new else will create unwanted duplicates.
|
||||
var v1 = isLiberated(book);
|
||||
d.RemoveField("IsLiberated");
|
||||
d.RemoveField("isliberated");
|
||||
d.AddBool("IsLiberated", v1);
|
||||
d.RemoveField("Liberated");
|
||||
d.RemoveField("liberated");
|
||||
d.AddBool("Liberated", v1);
|
||||
|
||||
var v2 = liberatedError(book);
|
||||
d.RemoveField("LiberatedError");
|
||||
d.RemoveField("liberatederror");
|
||||
d.AddBool("LiberatedError", v2);
|
||||
});
|
||||
|
||||
@ -301,9 +301,9 @@ namespace LibationSearchEngine
|
||||
// fields are key value pairs. MULTIPLE FIELDS CAN POTENTIALLY HAVE THE SAME KEY.
|
||||
// ie: must remove old before adding new else will create unwanted duplicates.
|
||||
var v1 = userOverallRating(book);
|
||||
d.RemoveField("UserRating");
|
||||
d.RemoveField("userrating");
|
||||
d.AddNotAnalyzed("UserRating", v1);
|
||||
d.RemoveField("MyRating");
|
||||
d.RemoveField("myrating");
|
||||
d.AddNotAnalyzed("MyRating", v1);
|
||||
});
|
||||
|
||||
|
||||
@ -14,7 +14,8 @@ namespace LibationWinForms.GridView
|
||||
private const string HOLLOW_STAR = "☆";
|
||||
|
||||
private Rating _rating;
|
||||
public Rating Rating {
|
||||
public Rating Rating
|
||||
{
|
||||
get => _rating;
|
||||
set
|
||||
{
|
||||
@ -32,6 +33,7 @@ namespace LibationWinForms.GridView
|
||||
star.Tag = star.Text = _rating.StoryRating > rating++ ? SOLID_STAR : HOLLOW_STAR;
|
||||
}
|
||||
}
|
||||
|
||||
public MyRatingCellEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
@ -102,15 +104,11 @@ namespace LibationWinForms.GridView
|
||||
|
||||
#region IDataGridViewEditingControl
|
||||
|
||||
DataGridView dataGridView;
|
||||
private bool valueChanged = false;
|
||||
int rowIndex;
|
||||
|
||||
public DataGridView EditingControlDataGridView { get => dataGridView; set => dataGridView = value; }
|
||||
public int EditingControlRowIndex { get => rowIndex; set => rowIndex = value; }
|
||||
public bool EditingControlValueChanged { get => valueChanged; set => valueChanged = value; }
|
||||
public DataGridView EditingControlDataGridView { get; set; }
|
||||
public int EditingControlRowIndex { get; set; }
|
||||
public bool EditingControlValueChanged { get; set; }
|
||||
public object EditingControlFormattedValue { get => Rating; set => Rating = (Rating)value; }
|
||||
public Cursor EditingPanelCursor => base.Cursor;
|
||||
public Cursor EditingPanelCursor => Cursor;
|
||||
public bool RepositionEditingControlOnValueChange => false;
|
||||
|
||||
public void ApplyCellStyleToEditingControl(DataGridViewCellStyle dataGridViewCellStyle)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user