public long IndexOf(ICacheableItem item) { if (item == null || item.CacheModelId != CacheId) { return(-1); } return(IndexOf(item.CacheEntryId)); }
public void RestoreSelection() { if (saved_selection) { long selected_id = -1; long first_id = FirstOrderId; // Compensate for the first, fake 'All *' item if (has_select_all_item) { first_id -= 1; } model.Selection.Clear(false); foreach (long order_id in connection.QueryEnumerable <long> (get_selection_command)) { selected_id = order_id - first_id; model.Selection.QuietSelect((int)selected_id); } if (has_select_all_item && model.Selection.Count == 0) { model.Selection.QuietSelect(0); } if (saved_focus_item != null) { long i = IndexOf(saved_focus_item); if (i != -1) { // TODO get rid of int cast model.Selection.FocusedIndex = (int)i; } } saved_selection = false; saved_focus_item = null; } }
public void SaveSelection() { if (model.Selection != null && model.Selection.Count > 0 && !(has_select_all_item && model.Selection.AllSelected)) { connection.Execute(delete_selection_command); saved_selection = true; if (!has_select_all_item && model.Selection.FocusedIndex != -1) { T item = GetValue(model.Selection.FocusedIndex); if (item != null) { saved_focus_item = GetValue(model.Selection.FocusedIndex); } } long start, end; foreach (Hyena.Collections.RangeCollection.Range range in model.Selection.Ranges) { start = range.Start; end = range.End; // Compensate for the first, fake 'All *' item if (has_select_all_item) { start -= 1; end -= 1; } connection.Execute(save_selection_command, start, end - start + 1); } } else { saved_selection = false; } }