| 38 } |
38 } |
| 39 |
39 |
| 40 static void* getvalue_wrapper(UiList *list, void *elm, int row, int col, void *userdata, UiBool *freeResult) { |
40 static void* getvalue_wrapper(UiList *list, void *elm, int row, int col, void *userdata, UiBool *freeResult) { |
| 41 ui_getvaluefunc getvalue = (ui_getvaluefunc)userdata; |
41 ui_getvaluefunc getvalue = (ui_getvaluefunc)userdata; |
| 42 return getvalue(elm, col); |
42 return getvalue(elm, col); |
| |
43 } |
| |
44 |
| |
45 static void* null_getvalue(UiList *list, void *elm, int row, int col, void *userdata, UiBool *freeResult) { |
| |
46 return NULL; |
| 43 } |
47 } |
| 44 |
48 |
| 45 UIWIDGET ui_listview_create(UiObject* obj, UiListArgs *args) { |
49 UIWIDGET ui_listview_create(UiObject* obj, UiListArgs *args) { |
| 46 UiContainerPrivate *ctn = ui_obj_container(obj); |
50 UiContainerPrivate *ctn = ui_obj_container(obj); |
| 47 UI_APPLY_LAYOUT(ctn->layout, args); |
51 UI_APPLY_LAYOUT(ctn->layout, args); |
| 100 view->setSelectionMode(QAbstractItemView::ExtendedSelection); |
104 view->setSelectionMode(QAbstractItemView::ExtendedSelection); |
| 101 } |
105 } |
| 102 |
106 |
| 103 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->list, args->varname, UI_VAR_LIST); |
107 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->list, args->varname, UI_VAR_LIST); |
| 104 |
108 |
| 105 TableModel *model = new TableModel(obj, view, var, args->model); |
109 ui_getvaluefunc2 getvalue = args->getvalue2; |
| |
110 void *getvaluedata = args->getvalue2data; |
| |
111 if(!getvalue) { |
| |
112 if(args->getvalue) { |
| |
113 getvalue = getvalue_wrapper; |
| |
114 getvaluedata = (void*)args->getvalue; |
| |
115 } else { |
| |
116 getvalue = null_getvalue; |
| |
117 } |
| |
118 } |
| |
119 TableModel *model = new TableModel(obj, view, var, args->model, getvalue, getvaluedata); |
| 106 view->setModel(model); |
120 view->setModel(model); |
| 107 |
121 |
| 108 if(var) { |
122 if(var) { |
| 109 UiList *list = (UiList*)var->value; |
123 UiList *list = (UiList*)var->value; |
| 110 list->update = ui_listmodel_update; |
124 list->update = ui_listmodel_update; |