void PerformSearch() { // For some reason, the matches column must be rebuilt // every time because otherwise, it's not sortable. RemoveMatchesColumn (); Search search = new Search(manager); string text = SearchText; if (text == null) { current_matches.Clear (); store_filter.Refilter (); UpdateTotalNoteCount (store_sort.IterNChildren ()); if (tree.IsRealized) tree.ScrollToPoint (0, 0); return; } text = text.ToLower (); current_matches.Clear (); // Search using the currently selected notebook Notebooks.Notebook selected_notebook = GetSelectedNotebook (); if (selected_notebook is Notebooks.SpecialNotebook) selected_notebook = null; IDictionary<Note,int> results = search.SearchNotes(text, false, selected_notebook); // if no results found in current notebook ask user whether // to search in all notebooks if (results.Count == 0 && selected_notebook != null) { NoMatchesFoundAction (); } else { foreach (Note note in results.Keys){ current_matches.Add (note.Uri, results[note]); } AddMatchesColumn (); store_filter.Refilter (); tree.ScrollToPoint (0, 0); UpdateMatchNoteCount (current_matches.Count); } }
public string[] SearchNotes (string query, bool case_sensitive) { if (query == null) return null; Search search = new Search(note_manager); List<string> list = new List<string>(); IDictionary<Note,int> results = search.SearchNotes(query, case_sensitive, null); foreach (Note note in results.Keys) { list.Add (note.Uri); } return list.ToArray (); }