void UpdateResults ()
{
// Save the currently selected notes
List<Note> selected_notes = GetSelectedNotes ();
int sort_column = 2; /* change date */
Gtk.SortType sort_type = Gtk.SortType.Descending;
if (store_sort != null)
store_sort.GetSortColumnId (out sort_column, out sort_type);
store = new Gtk.ListStore (column_types);
store_filter = new Gtk.TreeModelFilter (store, null);
store_filter.VisibleFunc = FilterNotes;
store_sort = new Gtk.TreeModelSort (store_filter);
store_sort.SetSortFunc (1 /* title */,
new Gtk.TreeIterCompareFunc (CompareTitles));
store_sort.SetSortFunc (2 /* change date */,
new Gtk.TreeIterCompareFunc (CompareDates));
int cnt = 0;
foreach (Note note in manager.Notes) {
string nice_date =
GuiUtils.GetPrettyPrintDate (note.ChangeDate, true);
store.AppendValues (note_icon, /* icon */
note.Title, /* title */
nice_date, /* change date */
note); /* note */
cnt++;
}
tree.Model = store_sort;
PerformSearch ();
if (sort_column >= 0) {
// Set the sort column after loading data, since we
// don't want to resort on every append.
store_sort.SetSortColumnId (sort_column, sort_type);
}
// Restore the previous selection
if (selected_notes != null && selected_notes.Count > 0) {
SelectNotes (selected_notes);
}
}