implemented search filter

This commit is contained in:
Lynne Megido 2020-09-05 17:10:35 +10:00
parent 74e1df9551
commit 259193de8b
Signed by: lynnesbian
GPG Key ID: F0A184B5213D9F90
2 changed files with 9 additions and 2 deletions

View File

@ -47,6 +47,7 @@ namespace Buypeeb {
private Box selectionViewBox;
private Label endingLabel;
private bool queueActive;
private SearchEntry searchEntry;
private Dictionary<string, CheckButton> filterChecks = new Dictionary<string, CheckButton>();
// ...to here.
@ -108,6 +109,7 @@ namespace Buypeeb {
this.selectionViewBox = (Box)builder.GetObject("SelectionViewBox");
this.endingLabel = (Label)builder.GetObject("LabelSelectedEnding");
this.searchEntry = (SearchEntry)builder.GetObject("FilterSearchEntry");
foreach (var name in new List<string> { "Favourites", "NonFavourites", "Active", "Ended", "EndingToday", "EndingAfterToday", "WithWinPrice", "WithNoWinPrice" }) {
this.filterChecks.Add(name, (CheckButton)builder.GetObject($"CheckButtonFilter{name}"));
this.filterChecks[name].Active = false;
@ -123,7 +125,10 @@ namespace Buypeeb {
(item.endingToday != this.filterChecks["EndingToday"].Active ||
item.endingToday == this.filterChecks["EndingAfterToday"].Active) &&
(item.hasWinPrice != this.filterChecks["WithWinPrice"].Active ||
item.hasWinPrice == this.filterChecks["WithNoWinPrice"].Active)
item.hasWinPrice == this.filterChecks["WithNoWinPrice"].Active) &&
(String.IsNullOrWhiteSpace(this.searchEntry.Text) ||
item.name.ToLower().Contains(this.searchEntry.Text.ToLower()) ||
item.originalName.ToLower().Contains(this.searchEntry.Text.ToLower()))
select item;
Console.WriteLine(this.filterChecks["Favourites"].Active);

View File

@ -457,13 +457,15 @@
<property name="margin_end">3</property>
<property name="spacing">3</property>
<child>
<object class="GtkSearchEntry">
<object class="GtkSearchEntry" id="FilterSearchEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
<signal name="activate" handler="RunFilter" swapped="no"/>
<signal name="changed" handler="RunFilter" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>