| 26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
| 27 */ |
27 */ |
| 28 |
28 |
| 29 #include "model.h" |
29 #include "model.h" |
| 30 |
30 |
| 31 static void* model_getvalue(UiModel *model, UiList *list, void *elm, int row, int col, UiBool *freeResult) { |
|
| 32 if(model->getvalue2) { |
|
| 33 return model->getvalue2(list, elm, row, col, model->getvalue2data, freeResult); |
|
| 34 } else if(model->getvalue) { |
|
| 35 return model->getvalue(elm, col); |
|
| 36 } |
|
| 37 return NULL; |
|
| 38 } |
|
| 39 |
31 |
| 40 ListModel::ListModel(UiObject *obj, QListView *view, UiVar *var, ui_getvaluefunc2 getvalue, void *getvaluedata){ |
32 ListModel::ListModel(UiObject *obj, QListView *view, UiVar *var, ui_getvaluefunc2 getvalue, void *getvaluedata){ |
| 41 this->obj = obj; |
33 this->obj = obj; |
| 42 this->view = view; |
34 this->view = view; |
| 43 this->var = var; |
35 this->var = var; |
| 114 free(sel.rows); |
106 free(sel.rows); |
| 115 } |
107 } |
| 116 |
108 |
| 117 |
109 |
| 118 |
110 |
| 119 TableModel::TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model){ |
111 TableModel::TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model, ui_getvaluefunc2 getvalue, void *getvaluedata){ |
| 120 this->obj = obj; |
112 this->obj = obj; |
| 121 this->view = view; |
113 this->view = view; |
| 122 this->var = var; |
114 this->var = var; |
| 123 this->model = model; |
115 this->model = model; |
| |
116 this->getvalue = getvalue; |
| |
117 this->getvaluedata = getvaluedata; |
| 124 this->onactivate = nullptr; |
118 this->onactivate = nullptr; |
| 125 this->onactivatedata = nullptr; |
119 this->onactivatedata = nullptr; |
| 126 this->onselection = nullptr; |
120 this->onselection = nullptr; |
| 127 this->onselectiondata = nullptr; |
121 this->onselectiondata = nullptr; |
| 128 } |
122 } |
| 160 UiList *ls = (UiList*)var->value; |
154 UiList *ls = (UiList*)var->value; |
| 161 void *rowData = ls->get(ls, index.row()); |
155 void *rowData = ls->get(ls, index.row()); |
| 162 if(rowData) { |
156 if(rowData) { |
| 163 int col = index.column(); |
157 int col = index.column(); |
| 164 UiBool freeResult = false; |
158 UiBool freeResult = false; |
| 165 void *value = model_getvalue(model, ls, rowData, index.row(), col, &freeResult); |
159 void *value = getvalue(ls, rowData, index.row(), col, getvaluedata, &freeResult); |
| 166 if(value) { |
160 if(value) { |
| 167 UiModelType type = model->types[col]; |
161 UiModelType type = model->types[col]; |
| 168 switch(type) { |
162 switch(type) { |
| 169 case UI_STRING: { |
163 case UI_STRING: { |
| 170 auto qs = QString::fromUtf8((char*)value); |
164 auto qs = QString::fromUtf8((char*)value); |