private void readd_everything() {
// at this point, I have all the notes in "sorted notes" set up correctly - I need to show them in the UI
var copy = notes_sorted_by_line_index_.ToList();
var sel_note_id = notesCtrl.SelectedIndex >= 0 ? (notesCtrl.GetItem(notesCtrl.SelectedIndex).RowObject as note_item).note_id : "";
var sel_note_id_above = find_note_id_above_selection();
++ignore_change_;
notes_sorted_by_line_index_.Clear();
notesCtrl.ClearObjects();
// ... re-add everything
//
// note: if any chidren of a deleted note/line is !deleted, we need to show that note/line (even if shown in gray)
// normally, this should not happen - however, I see this as a possibility when merging two notes files
// say X deletes note N, but Y replies on it
foreach ( var n in copy) {
if (n.is_note_header)
add_note_header(n.line_id, n.note_id, n.ui_deleted, n.utc_last_edited).deleted = n.deleted;
else
add_note(lines_[n.line_id], n.the_note, n.note_id, n.reply_id, n.ui_deleted, n.utc_last_edited).deleted = n.deleted;
}
Debug.Assert(notes_sorted_by_line_index_.Count == copy.Count);
// set current line
if (showDeletedLines.Checked) {
var cur_line_copy = new line();
cur_line_copy.copy_from(cur_line);
cur_line.clear();
set_current_line_impl(cur_line_copy);
} else
cur_line.clear();
string new_sel = showDeletedLines.Checked ? sel_note_id : sel_note_id_above;
if ( new_sel != "")
for ( int idx = 0; idx < notesCtrl.GetItemCount(); ++idx)
if ((notesCtrl.GetItem(idx).RowObject as note_item).note_id == new_sel) {
notesCtrl.SelectedIndex = idx;
notesCtrl.EnsureVisible(idx);
break;
}
--ignore_change_;
refresh_notes();
}