Skip to content

Commit 259da60

Browse files
committed
Improve hpcf filtering logic
Validated headphone lists in show history function. This will handle the case of misalignment between applied filter and active DB
1 parent 094c0ff commit 259da60

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

ash_toolset/__main__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,10 @@ def intialise_gui():
178178

179179
hpcf_is_active=dpg.get_value('e_apo_hpcf_conv')
180180
brir_is_active=dpg.get_value('e_apo_brir_conv')
181-
#show hpcf history
182-
cb.qc_show_hpcf_history(app_data=dpg.get_value('qc_toggle_hpcf_history'))
181+
#show hpcf history but only run function if enabled
182+
hpcf_hist_toggled = dpg.get_value('qc_toggle_hpcf_history')
183+
if hpcf_hist_toggled:
184+
cb.qc_show_hpcf_history(app_data=hpcf_hist_toggled)
183185

184186
cb.e_apo_toggle_hpcf_custom(activate=hpcf_is_active, aquire_config=False)
185187
cb.e_apo_toggle_brir_custom(activate=brir_is_active, aquire_config=False)
@@ -386,6 +388,7 @@ def intialise_gui():
386388
qc_hp_list_loaded, loaded_values["qc_hpcf_headphone"] = hf.ensure_valid_selection(qc_hp_list_loaded, loaded_values.get("qc_hpcf_headphone", ""))
387389
qc_sample_list_loaded = hpcf_functions.get_samples_list(conn_comp, loaded_values["qc_hpcf_headphone"])
388390
qc_sample_list_loaded, loaded_values["qc_hpcf_sample"] = hf.ensure_valid_selection(qc_sample_list_loaded, loaded_values.get("qc_hpcf_sample", ""))
391+
389392

390393
fde_brands_list_loaded = hpcf_functions.get_brand_list(conn_comp)
391394
fde_brands_list_loaded, loaded_values["fde_hpcf_brand"] = hf.ensure_valid_selection( fde_brands_list_loaded, loaded_values.get("fde_hpcf_brand", ""))

ash_toolset/callbacks.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def qc_show_hpcf_history(sender=None, app_data=None):
796796
hpcf_database_sel = dpg.get_value('qc_hpcf_active_database')
797797

798798

799-
#toggled on and there are saved filters
799+
#toggled on and there are saved filters -> populate lists with saved filters
800800
if headphone_list_saved and headphone_list_saved != None and app_data == True:
801801
#if selected headphone is in history, set default to selected, otherwise pick first value
802802
default_headphone = headphone_selected if headphone_selected in headphone_list_saved else headphone_list_saved[0]
@@ -828,7 +828,16 @@ def qc_show_hpcf_history(sender=None, app_data=None):
828828
#reset sample list to Sample A
829829
dpg.set_value("qc_hpcf_sample", sample_new)
830830

831+
#toggled off -> populate list with previously applied filters
831832
else:
833+
#validate lists in case of misalignment between applied filter and current DB, will reset
834+
brands_list, brand_selected = hf.ensure_valid_selection( brands_list, brand_selected)
835+
hp_list_selected = hpcf_functions.get_headphone_list(conn, brand_selected)#
836+
hp_list_selected, headphone_selected = hf.ensure_valid_selection(hp_list_selected, headphone_selected)
837+
sample_list_specific = hpcf_functions.get_samples_list(conn, headphone_selected)
838+
sample_list_sorted = (sorted(sample_list_specific))
839+
sample_list_sorted, sample_selected = hf.ensure_valid_selection(sample_list_sorted, sample_selected)
840+
832841
#reset brand list
833842
dpg.configure_item('qc_hpcf_brand',items=brands_list)
834843
#reset brand value to first brand
@@ -838,8 +847,7 @@ def qc_show_hpcf_history(sender=None, app_data=None):
838847
dpg.configure_item('qc_hpcf_headphone',items=hp_list_selected)
839848
dpg.set_value("qc_hpcf_headphone", headphone_selected)
840849
#also update sample list
841-
sample_list_specific = hpcf_functions.get_samples_list(conn, headphone_selected)
842-
sample_list_sorted = (sorted(sample_list_specific))
850+
843851
dpg.configure_item('qc_hpcf_sample',items=sample_list_sorted)
844852
#also update plot
845853
hpcf_functions.hpcf_to_plot(conn, headphone_selected, sample_selected, plot_type=2)

0 commit comments

Comments
 (0)