From: Olaf Wintermann Date: Mon, 28 Jul 2025 19:17:56 +0000 (+0200) Subject: implement nbconfig grouplist move up/down X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=f8f55f19b07bbbae0facf2a3b89cb31754e1ef69;p=note.git implement nbconfig grouplist move up/down --- diff --git a/application/nbconfig.c b/application/nbconfig.c index 213dbbd..62f5139 100644 --- a/application/nbconfig.c +++ b/application/nbconfig.c @@ -34,6 +34,10 @@ #include "store.h" #include "notebook.h" +static UiBool notebooklist_move_inprogress = FALSE; +static int notebooklist_move_pos0 = 0; +static int notebooklist_move_pos1 = 0; + static void* reslist_getvalue(void *data, int col) { Resource *resource = data; switch(col) { @@ -146,12 +150,53 @@ static void nbconfig_grouplist_delete(UiEvent *event, void *userdata) { } +static void nbconfig_grouplist_move_result(UiEvent *event, int error, void *userdata) { + notebooklist_move_inprogress = FALSE; + if(!error) { + NotebookConfigDialog *wdata = event->window; + cxListSwap(wdata->notebooks, notebooklist_move_pos0, notebooklist_move_pos1); + nbconfig_update_lists(wdata); + } else { + printf("nbconfig_notebooklist_move_up_result: error %d\n", error); + } +} + static void nbconfig_grouplist_move_up(UiEvent *event, void *userdata) { + if(notebooklist_move_inprogress) { + return; + } + NotebookConfigDialog *wdata = event->window; + UiListSelection sel = ui_list_getselection(wdata->tab1_groups); + if(sel.count == 1 && sel.rows[0] > 0) { + int row = sel.rows[0]; + notebooklist_move_pos0 = row; + notebooklist_move_pos1 = row-1; + Resource *r0 = cxListAt(wdata->groups, notebooklist_move_pos0); + Resource *r1 = cxListAt(wdata->groups, notebooklist_move_pos1); + note_store_notebook_swap_position_async(event->obj, r0->notebook, r1->notebook, nbconfig_grouplist_move_result, NULL); + notebooklist_move_inprogress = TRUE; + } + ui_listselection_free(sel); } static void nbconfig_grouplist_move_down(UiEvent *event, void *userdata) { + if(notebooklist_move_inprogress) { + return; + } + NotebookConfigDialog *wdata = event->window; + UiListSelection sel = ui_list_getselection(wdata->tab1_groups); + if(sel.count == 1 && sel.rows[0] > 0) { + int row = sel.rows[0]; + notebooklist_move_pos0 = row; + notebooklist_move_pos1 = row+1; + Resource *r0 = cxListAt(wdata->groups, notebooklist_move_pos0); + Resource *r1 = cxListAt(wdata->groups, notebooklist_move_pos1); + note_store_notebook_swap_position_async(event->obj, r0->notebook, r1->notebook, nbconfig_grouplist_move_result, NULL); + notebooklist_move_inprogress = TRUE; + } + ui_listselection_free(sel); } static void nbconfig_grouplist_name_changed(UiEvent *event, void *userdata) { @@ -234,10 +279,6 @@ static void nbconfig_notebooklist_delete(UiEvent *event, void *userdata) { ui_listselection_free(sel); } -static UiBool notebooklist_move_inprogress = FALSE; -static int notebooklist_move_pos0 = 0; -static int notebooklist_move_pos1 = 0; - static void nbconfig_notebooklist_move_result(UiEvent *event, int error, void *userdata) { notebooklist_move_inprogress = FALSE; if(!error) {