feat(slint): search box for the favorites Labels tab
Add an ExpandableSearch to the Labels toolbar (mirrors tracks/albums), wired to labels-search + the new derive_labels controller fn, which forks a name-filtered clone of the loaded labels and shares the full model when the query is empty (artwork stays live). apply_favorites now derives the visible set on load. cc
This commit is contained in:
4 files changed
+52
-2
No files matched your search
@@ -508,9 +508,10 @@ pub fn apply_favorites(window: &AppWindow, data: FavData) {
|
||||
// `labels-visible` (what the grid renders) shares it until a
|
||||
// search filter forks it, so artwork stays live.
|
||||
let model = ModelRc::new(VecModel::from(rows));
|
||||
state.set_labels(model.clone());
|
||||
state.set_labels_visible(model);
|
||||
state.set_labels(model);
|
||||
state.set_labels_total(total as i32);
|
||||
state.set_labels_search("".into());
|
||||
derive_labels(window);
|
||||
}
|
||||
}
|
||||
state.set_loading(false);
|
||||
@@ -580,6 +581,26 @@ pub fn derive_tracks(window: &AppWindow) {
|
||||
state.set_tracks_visible(ModelRc::new(VecModel::from(filtered)));
|
||||
}
|
||||
|
||||
/// Re-derive the rendered Labels grid (`labels-visible`) from the full
|
||||
/// `labels` set and the search query. An empty query shares the full
|
||||
/// model so artwork keeps updating in place; a query forks a filtered
|
||||
/// clone (name-only substring match, mirrors Tauri's filteredLabels).
|
||||
pub fn derive_labels(window: &AppWindow) {
|
||||
let state = window.global::<FavoritesState>();
|
||||
let query_owned = state.get_labels_search().to_lowercase();
|
||||
let query = query_owned.trim();
|
||||
let all = state.get_labels();
|
||||
if query.is_empty() {
|
||||
state.set_labels_visible(all);
|
||||
return;
|
||||
}
|
||||
let filtered: Vec<FavoriteLabelItem> = (0..all.row_count())
|
||||
.filter_map(|i| all.row_data(i))
|
||||
.filter(|l| l.name.to_lowercase().contains(query))
|
||||
.collect();
|
||||
state.set_labels_visible(ModelRc::new(VecModel::from(filtered)));
|
||||
}
|
||||
|
||||
/// The loaded favorite tracks as a play-ready queue (Play all).
|
||||
pub fn play_tracks() -> Vec<Track> {
|
||||
FAV_CURRENT.lock().map(|c| c.clone()).unwrap_or_default()
|
||||
|
||||
Reference in new issue
Block a user