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