--- a/ui/qt/model.cpp Tue Apr 22 20:40:01 2025 +0200 +++ b/ui/qt/model.cpp Thu Apr 24 21:19:29 2025 +0200 @@ -99,11 +99,11 @@ -TableModel::TableModel(UiObject *obj, QTreeView *view, UiVar *var, ui_getvaluefunc getvalue){ +TableModel::TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model){ this->obj = obj; this->view = view; this->var = var; - this->getvalue = getvalue; + this->model = model; this->onactivate = nullptr; this->onactivatedata = nullptr; this->onselection = nullptr; @@ -134,18 +134,30 @@ return ui_list_count(list); } +int TableModel::columnCount(const QModelIndex &parent) const { + return model->columns; +} + QVariant TableModel::data(const QModelIndex &index, int role) const { if(role == Qt::DisplayRole) { UiList *ls = (UiList*)var->value; void *rowData = ls->get(ls, index.row()); - if(rowData && getvalue) { - void *value = getvalue(rowData, 0); + if(rowData && model->getvalue) { + void *value = model->getvalue(rowData, index.column()); return QString::fromUtf8((char*)value); } } return QVariant(); } +QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const { + if(role == Qt::DisplayRole) { + char *label = model->titles[section]; + return QString::fromUtf8(label); + } + return QVariant(); +} + void TableModel::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { UiListSelection sel = ui_selection_model_to_selection(view->selectionModel());