diff options
author | Joan Lledó <jlledom@member.fsf.org> | 2023-09-30 13:06:01 +0200 |
---|---|---|
committer | Joan Lledó <jlledom@member.fsf.org> | 2023-09-30 13:14:53 +0200 |
commit | 14ae87d469555af8301356f99a11c2254edee1a4 (patch) | |
tree | 2ec472aeebd7d12d9c9ceb43c73122e8a61f5aca /src/ui | |
parent | c6d5440c44ac7b94a9d7db38c36e638097872852 (diff) | |
download | Furtherance-14ae87d469555af8301356f99a11c2254edee1a4.tar.zst |
Implement search by tag list
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/window.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/ui/window.rs b/src/ui/window.rs index ccf2364..8972ed9 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -208,9 +208,9 @@ impl FurtheranceWindow { .connect_changed(clone!(@weak self as this => move |task_input| { let imp2 = imp::FurtheranceWindow::from_obj(&this); let task_input_text = task_input.text(); - let split_tags: Vec<&str> = task_input_text.trim().split('#').collect(); - let task_name = split_tags[0]; - if task_name.trim().is_empty() { + let mut split_tags: Vec<String> = task_input_text.split('#').map(|tag| String::from(tag.trim())).collect(); + let task_name = split_tags.remove(0); + if task_name.is_empty() { imp2.start_button.set_sensitive(false); } else { imp2.start_button.set_sensitive(true); @@ -218,7 +218,7 @@ impl FurtheranceWindow { if task_input.text().len() >= FurtheranceWindow::MIN_PREFIX_LENGTH.try_into().unwrap() { let task_autocomplete = task_input.completion().unwrap(); - let model = Self::update_list_model(task_name.to_string()).unwrap(); + let model = Self::update_list_model(task_name.to_string(), split_tags).unwrap(); task_autocomplete.set_model(Some(&model)); } })); @@ -544,9 +544,9 @@ impl FurtheranceWindow { imp.task_input.set_activates_default(true); } - fn update_list_model(task_name: String) -> Result<gtk::ListStore, anyhow::Error> { + fn update_list_model(task_name: String, tag_list: Vec<String>) -> Result<gtk::ListStore, anyhow::Error> { let col_types: [glib::Type; 1] = [glib::Type::STRING]; - let mut task_list = database::get_list_by_name(task_name)?; + let mut task_list = database::get_list_by_name_and_tags(task_name, tag_list)?; task_list.dedup_by(|a, b| a.task_name == b.task_name && a.tags == b.tags); let store = gtk::ListStore::new(&col_types); |