fix QT build

Sun, 24 Aug 2025 15:05:00 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 24 Aug 2025 15:05:00 +0200
changeset 723
e513086eadbb
parent 722
6466b4f16e5e
child 724
ba7a2f7675b9

fix QT build

application/main.c file | annotate | diff | comparison | revisions
ui/gtk/list.c file | annotate | diff | comparison | revisions
ui/qt/list.cpp file | annotate | diff | comparison | revisions
ui/qt/model.cpp file | annotate | diff | comparison | revisions
ui/qt/model.h file | annotate | diff | comparison | revisions
ui/ui/button.h file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Aug 24 14:58:27 2025 +0200
+++ b/application/main.c	Sun Aug 24 15:05:00 2025 +0200
@@ -1002,8 +1002,7 @@
         
         UiModel *model = ui_model(obj->ctx, UI_STRING, "col1", UI_INTEGER, "col2", -1);
         model->columnsize[0] = -1;
-        model->getvalue = table_getvalue;
-        ui_table(obj, .model = model, .varname = "mylist", .colspan = 2, .fill = UI_ON, .multiselection = TRUE, .fill = TRUE, .onactivate = list_activate);
+        ui_table(obj, .model = model, .getvalue = table_getvalue, .varname = "mylist", .colspan = 2, .fill = UI_ON, .multiselection = TRUE, .fill = TRUE, .onactivate = list_activate);
         
         ui_newline(obj);
         
--- a/ui/gtk/list.c	Sun Aug 24 14:58:27 2025 +0200
+++ b/ui/gtk/list.c	Sun Aug 24 15:05:00 2025 +0200
@@ -1144,8 +1144,6 @@
 UIWIDGET ui_combobox_create(UiObject *obj, UiListArgs *args) {
     UiObject* current = uic_current_obj(obj);
     
-    //GtkWidget *combobox = ui_create_combobox(obj, model, var, args->static_elements, args->static_nelm, args->onactivate, args->onactivatedata);
-    
     GtkWidget *combobox = gtk_combo_box_new();
     
     ui_set_name_and_style(combobox, args->name, args->style_class);
--- a/ui/qt/list.cpp	Sun Aug 24 14:58:27 2025 +0200
+++ b/ui/qt/list.cpp	Sun Aug 24 15:05:00 2025 +0200
@@ -42,6 +42,10 @@
     return getvalue(elm, col);
 }
 
+static void* null_getvalue(UiList *list, void *elm, int row, int col, void *userdata, UiBool *freeResult) {
+    return NULL;
+}
+
 UIWIDGET ui_listview_create(UiObject* obj, UiListArgs *args) {
     UiContainerPrivate *ctn = ui_obj_container(obj);
     UI_APPLY_LAYOUT(ctn->layout, args);
@@ -102,7 +106,17 @@
     
     UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->list, args->varname, UI_VAR_LIST);
     
-    TableModel *model = new TableModel(obj, view, var, args->model);
+    ui_getvaluefunc2 getvalue = args->getvalue2;
+    void *getvaluedata = args->getvalue2data;
+    if(!getvalue) {
+        if(args->getvalue) {
+            getvalue = getvalue_wrapper;
+            getvaluedata = (void*)args->getvalue;
+        } else {
+            getvalue = null_getvalue;
+        }
+    }
+    TableModel *model = new TableModel(obj, view, var, args->model, getvalue, getvaluedata);
     view->setModel(model);
     
     if(var) {
--- a/ui/qt/model.cpp	Sun Aug 24 14:58:27 2025 +0200
+++ b/ui/qt/model.cpp	Sun Aug 24 15:05:00 2025 +0200
@@ -28,14 +28,6 @@
 
 #include "model.h"
 
-static void* model_getvalue(UiModel *model, UiList *list, void *elm, int row, int col, UiBool *freeResult) {
-    if(model->getvalue2) {
-        return model->getvalue2(list, elm, row, col, model->getvalue2data, freeResult);
-    } else if(model->getvalue) {
-        return model->getvalue(elm, col);
-    }
-    return NULL;
-}
 
 ListModel::ListModel(UiObject *obj, QListView *view, UiVar *var, ui_getvaluefunc2 getvalue, void *getvaluedata){
     this->obj = obj;
@@ -116,11 +108,13 @@
 
 
 
-TableModel::TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model){
+TableModel::TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model, ui_getvaluefunc2 getvalue, void *getvaluedata){
     this->obj = obj;
     this->view = view;
     this->var = var;
     this->model = model;
+    this->getvalue = getvalue;
+    this->getvaluedata = getvaluedata;
     this->onactivate = nullptr;
     this->onactivatedata = nullptr;
     this->onselection = nullptr;
@@ -162,7 +156,7 @@
         if(rowData) {
             int col = index.column();
             UiBool freeResult = false;
-            void *value = model_getvalue(model, ls, rowData, index.row(), col, &freeResult);
+            void *value = getvalue(ls, rowData, index.row(), col, getvaluedata, &freeResult);
             if(value) {
                 UiModelType type = model->types[col];
                 switch(type) {
--- a/ui/qt/model.h	Sun Aug 24 14:58:27 2025 +0200
+++ b/ui/qt/model.h	Sun Aug 24 15:05:00 2025 +0200
@@ -45,7 +45,7 @@
     Q_OBJECT
     
     ui_getvaluefunc2 getvalue;
-    void *getvaluedata;
+    void        *getvaluedata;
     ui_callback onactivate;
     void        *onactivatedata;
     ui_callback onselection;
@@ -75,18 +75,20 @@
 class TableModel : public QAbstractListModel {
     Q_OBJECT
     
-    UiModel     *model;
-    ui_callback onactivate;
-    void        *onactivatedata;
-    ui_callback onselection;
-    void        *onselectiondata;
+    UiModel          *model;
+    ui_getvaluefunc2 getvalue;
+    void             *getvaluedata;
+    ui_callback      onactivate;
+    void             *onactivatedata;
+    ui_callback      onselection;
+    void             *onselectiondata;
     
 public:
-    UiObject    *obj;
-    UiVar       *var;
-    QTreeView   *view;
+    UiObject         *obj;
+    UiVar            *var;
+    QTreeView        *view;
     
-    TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model);
+    TableModel(UiObject *obj, QTreeView *view, UiVar *var, UiModel *model, ui_getvaluefunc2 getvalue, void *getvaluedata);
     
     void setActivationCallback(ui_callback f, void *userdata);
     void setSelectionCallback(ui_callback f, void *userdata);
--- a/ui/ui/button.h	Sun Aug 24 14:58:27 2025 +0200
+++ b/ui/ui/button.h	Sun Aug 24 15:05:00 2025 +0200
@@ -35,11 +35,11 @@
 extern "C" {
 #endif
 
-typedef enum UiLinkType UiLinkType;
 enum UiLinkType {
     UI_LINK_TEXT = 0,
     UI_LINK_BUTTON
 };
+typedef enum UiLinkType UiLinkType;
     
 typedef struct UiButtonArgs {
     UiBool fill;

mercurial