return model;
}
+static void notelist_select_note(NotebookModel *model, Note *note) {
+ CxList *list = model->notes->data; // UiList uses CxList internally
+ list->collection.cmpfunc = cx_cmp_ptr;
+ int index = (int)cxListFind(list, note);
+ if(cxListIndexValid(list, index)) {
+ ui_list_setselection(model->notes, index);
+ }
+}
+
void notebookmodel_attach(MainWindow *window, NotebookModel *model) {
if(window->current_notebook) {
notebookmodel_detach(window->current_notebook);
window->current_notebook = model;
model->window = window;
ui_list_update(model->notes); // TODO: this should be unnecessary, attaching the document should update all values
+
+ // TODO: Again, this should work automatically. Why it doesn't work:
+ // UiList selection is not saved (should the toolkit actually do it?)
+ // values from sub-values are bound but not reloaded
+ if(model->current_note) {
+ notelist_select_note(model, model->current_note);
+ // notebookmodel_attach_note(model, model->current_note);
+ }
}
void notebookmodel_detach(NotebookModel *model) {