Fri, 25 Apr 2025 22:04:30 +0200
implement more table column types (QT)
| ui/qt/model.cpp | file | annotate | diff | comparison | revisions |
--- a/ui/qt/model.cpp Thu Apr 24 21:19:29 2025 +0200 +++ b/ui/qt/model.cpp Fri Apr 25 22:04:30 2025 +0200 @@ -70,7 +70,9 @@ void *rowData = ls->get(ls, index.row()); if(rowData && getvalue) { void *value = getvalue(rowData, 0); - return QString::fromUtf8((char*)value); + if(value) { + return QString::fromUtf8((char*)value); + } } } return QVariant(); @@ -143,8 +145,34 @@ UiList *ls = (UiList*)var->value; void *rowData = ls->get(ls, index.row()); if(rowData && model->getvalue) { - void *value = model->getvalue(rowData, index.column()); - return QString::fromUtf8((char*)value); + int col = index.column(); + void *value = model->getvalue(rowData, col); + if(value) { + UiModelType type = model->types[col]; + switch(type) { + case UI_STRING: { + return QString::fromUtf8((char*)value); + } + case UI_STRING_FREE: { + QString s = QString::fromUtf8((char*)value); + free(value); + return s; + } + case UI_INTEGER: { + int *i = (int*)value; + return QString::number(*i); + } + case UI_ICON: { + break; + } + case UI_ICON_TEXT: { + break; + } + case UI_ICON_TEXT_FREE: { + break; + } + } + } } } return QVariant();