| 71 |
71 |
| 72 ctn->add(view, false); |
72 ctn->add(view, false); |
| 73 |
73 |
| 74 return view; |
74 return view; |
| 75 } |
75 } |
| |
76 |
| |
77 UIWIDGET ui_table_create(UiObject* obj, UiListArgs args) { |
| |
78 UiContainerPrivate *ctn = ui_obj_container(obj); |
| |
79 UI_APPLY_LAYOUT(ctn->layout, args); |
| |
80 |
| |
81 QTreeView *view = new QTreeView(); |
| |
82 view->setItemsExpandable(false); |
| |
83 view->setRootIsDecorated(false); |
| |
84 |
| |
85 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.list, args.varname, UI_VAR_LIST); |
| |
86 |
| |
87 TableModel *model = new TableModel(obj, view, var, args.model); |
| |
88 view->setModel(model); |
| |
89 |
| |
90 if(var) { |
| |
91 UiList *list = (UiList*)var->value; |
| |
92 list->update = ui_listmodel_update; |
| |
93 list->getselection = ui_listmodel_getselection; |
| |
94 list->setselection = ui_listmodel_setselection; |
| |
95 list->obj = model; |
| |
96 } |
| |
97 |
| |
98 model->setActivationCallback(args.onactivate, args.onactivatedata); |
| |
99 model->setSelectionCallback(args.onselection, args.onselectiondata); |
| |
100 |
| |
101 QItemSelectionModel *s = view->selectionModel(); |
| |
102 QObject::connect( |
| |
103 s, |
| |
104 SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), |
| |
105 model, |
| |
106 SLOT(selectionChanged(const QItemSelection &, const QItemSelection &))); |
| |
107 |
| |
108 |
| |
109 ctn->add(view, false); |
| |
110 |
| |
111 return view; |
| |
112 } |