implement more table column types (QT)

Fri, 25 Apr 2025 22:04:30 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Fri, 25 Apr 2025 22:04:30 +0200
changeset 583
30083c6cb198
parent 582
6c86efe60b37
child 584
12cca226c1eb
child 585
e71867b33bfd

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();

mercurial