]> saetta.ns0.it Git - libgdaex/commitdiff
Added functions GdaEx::fill_liststore_from_sql_with_missing_func and GdaEx::fill_list...
authorAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Fri, 2 Dec 2011 08:51:55 +0000 (09:51 +0100)
committerAndrea Zagli <a.zagli@comune.scandicci.fi.it>
Fri, 2 Dec 2011 08:51:55 +0000 (09:51 +0100)
.cproject [new file with mode: 0644]
.project [new file with mode: 0644]
src/gdaex.c
src/gdaex.h

diff --git a/.cproject b/.cproject
new file mode 100644 (file)
index 0000000..cbe5da2
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?fileVersion 4.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
+       <storageModule moduleId="org.eclipse.cdt.core.settings">
+               <cconfiguration id="cdt.managedbuild.toolchain.gnu.mingw.base.2008666082">
+                       <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.toolchain.gnu.mingw.base.2008666082" moduleId="org.eclipse.cdt.core.settings" name="Default">
+                               <externalSettings/>
+                               <extensions>
+                                       <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>
+                                       <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                                       <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
+                               </extensions>
+                       </storageModule>
+                       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+                               <configuration artifactName="libgdaex" buildProperties="" description="" id="cdt.managedbuild.toolchain.gnu.mingw.base.2008666082" name="Default" parent="org.eclipse.cdt.build.core.emptycfg">
+                                       <folderInfo id="cdt.managedbuild.toolchain.gnu.mingw.base.2008666082.1629362093" name="/" resourcePath="">
+                                               <toolChain id="cdt.managedbuild.toolchain.gnu.mingw.base.239345556" name="cdt.managedbuild.toolchain.gnu.mingw.base" superClass="cdt.managedbuild.toolchain.gnu.mingw.base">
+                                                       <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.PE" id="cdt.managedbuild.target.gnu.platform.mingw.base.1811874117" name="Debug Platform" osList="win32" superClass="cdt.managedbuild.target.gnu.platform.mingw.base"/>
+                                                       <builder buildPath="${workspace_loc:/libgdaex/Default}" id="cdt.managedbuild.tool.gnu.builder.mingw.base.437642443" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="CDT Internal Builder" superClass="cdt.managedbuild.tool.gnu.builder.mingw.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.assembler.mingw.base.249395220" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.mingw.base">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.assembler.input.1469065797" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.archiver.mingw.base.521466955" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.mingw.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base.1978833679" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.mingw.base"/>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.compiler.mingw.base.1090629218" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.mingw.base">
+                                                               <option id="gnu.c.compiler.option.include.paths.420212102" name="Include paths (-I)" superClass="gnu.c.compiler.option.include.paths" valueType="includePath">
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\mingw\include\glib-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\mingw\include\gtk-2.0&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;C:\mingw\include\libgda-4.0&quot;"/>
+                                                               </option>
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1969516801" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.c.linker.mingw.base.1141104592" name="MinGW C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.mingw.base">
+                                                               <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.1565299810" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
+                                                                       <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
+                                                                       <additionalInput kind="additionalinput" paths="$(LIBS)"/>
+                                                               </inputType>
+                                                       </tool>
+                                                       <tool id="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base.1409110738" name="MinGW C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.mingw.base"/>
+                                               </toolChain>
+                                       </folderInfo>
+                               </configuration>
+                       </storageModule>
+                       <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+               </cconfiguration>
+       </storageModule>
+       <storageModule moduleId="cdtBuildSystem" version="4.0.0">
+               <project id="libgdaex.null.618719898" name="libgdaex"/>
+       </storageModule>
+       <storageModule moduleId="scannerConfiguration">
+               <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+       </storageModule>
+       <storageModule moduleId="refreshScope" versionNumber="1">
+               <resource resourceType="PROJECT" workspacePath="/libgdaex"/>
+       </storageModule>
+</cproject>
diff --git a/.project b/.project
new file mode 100644 (file)
index 0000000..97b97f7
--- /dev/null
+++ b/.project
@@ -0,0 +1,315 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>libgdaex</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
+                       <triggers>clean,full,incremental,</triggers>
+                       <arguments>
+                               <dictionary>
+                                       <key>?name?</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.append_environment</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildArguments</key>
+                                       <value></value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildCommand</key>
+                                       <value>make</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.buildLocation</key>
+                                       <value>${workspace_loc:/libgdaex/Default}</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.contents</key>
+                                       <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
+                                       <value>false</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.enableFullBuild</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.stopOnError</key>
+                                       <value>true</value>
+                               </dictionary>
+                               <dictionary>
+                                       <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
+                                       <value>true</value>
+                               </dictionary>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
+                       <triggers>full,incremental,</triggers>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.cdt.core.cnature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
+               <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
+       </natures>
+       <filteredResources>
+               <filter>
+                       <id>1322811819863</id>
+                       <name></name>
+                       <type>30</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-autom4te.cache</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819866</id>
+                       <name></name>
+                       <type>30</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-m4</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819870</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-config.h</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819875</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-aclocal.m4</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819878</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-Makefile</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819881</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-Makefile.in</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819885</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.la</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819888</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.exe</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819891</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-config.guess</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819895</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-config.h.in*</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819898</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-config.log</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819902</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-config.status</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819905</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-config.sub</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819908</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-depcomp</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819912</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-gtk-doc.make</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819915</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-intltool*</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819918</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-install-sh</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819921</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.anjuta</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819924</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.pc</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819928</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-libtool</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819931</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-missing</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819934</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-mkinstalldirs</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819938</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-stamp-h1</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811819942</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-ltmain.sh</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811820098</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-configure</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811820101</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.o</arguments>
+                       </matcher>
+               </filter>
+               <filter>
+                       <id>1322811820117</id>
+                       <name></name>
+                       <type>22</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.lo</arguments>
+                       </matcher>
+               </filter>
+       </filteredResources>
+</projectDescription>
index cd9de2ec8c23b565d1eef397872fbdc1e4ec44bb..b7ee9d0d9ffc4a71d6b3c8666c5259ab7997e078 100644 (file)
@@ -2761,11 +2761,12 @@ GtkBuilder
 }
 
 void
-gdaex_fill_liststore_from_sql (GdaEx *gdaex,
-                               GtkListStore *lstore,
-                               const gchar *sql,
-                               guint *cols_formatted,
-                               gchar *(*cols_format_func) (GdaDataModelIter *, guint))
+gdaex_fill_liststore_from_sql_with_missing_func (GdaEx *gdaex,
+                                                 GtkListStore *lstore,
+                                                 const gchar *sql,
+                                                 guint *cols_formatted,
+                                                 gchar *(*cols_format_func) (GdaDataModelIter *, guint),
+                                                 GdaExFillListStoreMissingFunc missing_func, gpointer user_data)
 {
        GdaDataModel *dm;
 
@@ -2779,15 +2780,16 @@ gdaex_fill_liststore_from_sql (GdaEx *gdaex,
        g_return_if_fail (g_strcmp0 (_sql, "") != 0);
 
        dm = gdaex_query (gdaex, _sql);
-       gdaex_fill_liststore_from_datamodel (gdaex, lstore, dm, cols_formatted, cols_format_func);
+       gdaex_fill_liststore_from_datamodel_with_missing_func (gdaex, lstore, dm, cols_formatted, cols_format_func, missing_func, user_data);
 }
 
 void
-gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
-                                     GtkListStore *lstore,
-                                     GdaDataModel *dm,
-                                     guint *cols_formatted,
-                                     gchar *(*cols_format_func) (GdaDataModelIter *, guint))
+gdaex_fill_liststore_from_datamodel_with_missing_func (GdaEx *gdaex,
+                                                       GtkListStore *lstore,
+                                                       GdaDataModel *dm,
+                                                       guint *cols_formatted,
+                                                       gchar *(*cols_format_func) (GdaDataModelIter *, guint),
+                                                       GdaExFillListStoreMissingFunc missing_func, gpointer user_data)
 {
        GtkTreeIter iter;
 
@@ -2796,9 +2798,12 @@ gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
        guint cols;
        guint col;
 
-       GType *col_gtypes;
+       GdaColumn *gdacolumn;
 
+       GType *col_gtypes;
        GType *gcol_gtypes;
+       gboolean *col_missings;
+       gboolean call_missing_func;
 
        gint *columns;
        GValue *values;
@@ -2829,14 +2834,26 @@ gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
        values = (GValue *)g_new0 (GValue, cols);
        col_gtypes = (GType *)g_new0 (GType, cols);
        gcol_gtypes = (GType *)g_new0 (GType, cols);
+       col_missings = (gboolean *)g_new0 (gboolean, cols);
+
+       call_missing_func = FALSE;
 
        /* caching of columns types */
        for (col = 0; col < cols; col++)
                {
                        col_gtypes[col] = gtk_tree_model_get_column_type (GTK_TREE_MODEL (lstore), col);
-                       if (col_gtypes[col] == G_TYPE_STRING)
+
+                       gdacolumn = gda_data_model_describe_column (dm, col);
+                       if (gdacolumn == NULL)
                                {
-                                       gcol_gtypes[col] = gda_column_get_g_type (gda_data_model_describe_column (dm, col));
+                                       col_missings[col] = TRUE;
+                                       gcol_gtypes[col] = 0;
+                                       call_missing_func = TRUE;
+                               }
+                       else
+                               {
+                                       col_missings[col] = FALSE;
+                                       gcol_gtypes[col] = gda_column_get_g_type (gdacolumn);
                                }
                }
 
@@ -2853,67 +2870,102 @@ gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
                                        switch (col_gtypes[col])
                                                {
                                                        case G_TYPE_STRING:
-                                                               switch (gcol_gtypes[col])
+                                                               if (col_missings[col])
                                                                        {
-                                                                               case G_TYPE_STRING:
-                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_value_stringify_at (gda_iter, col));
-                                                                                       break;
-
-                                                                               case G_TYPE_BOOLEAN:
-                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_value_boolean_at (gda_iter, col) ? "X" : "");
-                                                                                       break;
-
-                                                                               case G_TYPE_INT:
-                                                                                       ival = gdaex_data_model_iter_get_value_integer_at (gda_iter, col);
-                                                                                       g_value_set_string (&gval, gdaex_format_money ((gdouble)ival, 0, FALSE));
-                                                                                       break;
-
-                                                                               case G_TYPE_FLOAT:
-                                                                               case G_TYPE_DOUBLE:
-                                                                                       dval = gdaex_data_model_iter_get_value_double_at (gda_iter, col);
-                                                                                       g_value_set_string (&gval, gdaex_format_money (dval, -1, FALSE));
-                                                                                       break;
-
-                                                                               default:
-                                                                                       if (cols_format_func != NULL)
-                                                                                               {
-                                                                                                       g_value_set_string (&gval, (*cols_format_func) (gda_iter, col));
-                                                                                               }
-                                                                                       else if (gcol_gtypes[col] == G_TYPE_DATE
-                                                                                                || gcol_gtypes[col] == GDA_TYPE_TIMESTAMP
-                                                                                                || gcol_gtypes[col] == G_TYPE_DATE_TIME)
-                                                                                               {
-                                                                                                       gdatetime = gdaex_data_model_iter_get_value_gdatetime_at (gda_iter, col);
-                                                                                                       /* TODO find default format from locale */
-                                                                                                       g_value_set_string (&gval, g_date_time_format (gdatetime, gcol_gtypes[col] == G_TYPE_DATE ? "%d/%m/%Y" : "%d/%m/%Y %H.%M.%S"));
-                                                                                               }
-                                                                                       else
-                                                                                               {
-                                                                                                       g_value_set_string (&gval, gda_value_stringify (gda_data_model_iter_get_value_at (gda_iter, col)));
-                                                                                               }
-                                                                                       break;
+                                                                               g_value_set_string (&gval, "");
+                                                                       }
+                                                               else
+                                                                       {
+                                                                               switch (gcol_gtypes[col])
+                                                                                       {
+                                                                                               case G_TYPE_STRING:
+                                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_value_stringify_at (gda_iter, col));
+                                                                                                       break;
+
+                                                                                               case G_TYPE_BOOLEAN:
+                                                                                                       g_value_set_string (&gval, gdaex_data_model_iter_get_value_boolean_at (gda_iter, col) ? "X" : "");
+                                                                                                       break;
+
+                                                                                               case G_TYPE_INT:
+                                                                                                       ival = gdaex_data_model_iter_get_value_integer_at (gda_iter, col);
+                                                                                                       g_value_set_string (&gval, gdaex_format_money ((gdouble)ival, 0, FALSE));
+                                                                                                       break;
+
+                                                                                               case G_TYPE_FLOAT:
+                                                                                               case G_TYPE_DOUBLE:
+                                                                                                       dval = gdaex_data_model_iter_get_value_double_at (gda_iter, col);
+                                                                                                       g_value_set_string (&gval, gdaex_format_money (dval, -1, FALSE));
+                                                                                                       break;
+
+                                                                                               default:
+                                                                                                       if (cols_format_func != NULL)
+                                                                                                               {
+                                                                                                                       g_value_set_string (&gval, (*cols_format_func) (gda_iter, col));
+                                                                                                               }
+                                                                                                       else if (gcol_gtypes[col] == G_TYPE_DATE
+                                                                                                                || gcol_gtypes[col] == GDA_TYPE_TIMESTAMP
+                                                                                                                || gcol_gtypes[col] == G_TYPE_DATE_TIME)
+                                                                                                               {
+                                                                                                                       gdatetime = gdaex_data_model_iter_get_value_gdatetime_at (gda_iter, col);
+                                                                                                                       /* TODO find default format from locale */
+                                                                                                                       g_value_set_string (&gval, g_date_time_format (gdatetime, gcol_gtypes[col] == G_TYPE_DATE ? "%d/%m/%Y" : "%d/%m/%Y %H.%M.%S"));
+                                                                                                               }
+                                                                                                       else
+                                                                                                               {
+                                                                                                                       g_value_set_string (&gval, gda_value_stringify (gda_data_model_iter_get_value_at (gda_iter, col)));
+                                                                                                               }
+                                                                                                       break;
+                                                                                       }
                                                                        }
 
                                                                values[col] = gval;
                                                                break;
 
                                                        case G_TYPE_INT:
-                                                               g_value_set_int (&gval, gdaex_data_model_iter_get_value_integer_at (gda_iter, col));
+                                                               if (col_missings[col])
+                                                                       {
+                                                                               g_value_set_int (&gval, 0);
+                                                                       }
+                                                               else
+                                                                       {
+                                                                               g_value_set_int (&gval, gdaex_data_model_iter_get_value_integer_at (gda_iter, col));
+                                                                       }
                                                                values[col] = gval;
                                                                break;
 
                                                        case G_TYPE_FLOAT:
-                                                               g_value_set_float (&gval, gdaex_data_model_iter_get_value_float_at (gda_iter, col));
+                                                               if (col_missings[col])
+                                                                       {
+                                                                               g_value_set_float (&gval, 0.0);
+                                                                       }
+                                                               else
+                                                                       {
+                                                                               g_value_set_float (&gval, gdaex_data_model_iter_get_value_float_at (gda_iter, col));
+                                                                       }
                                                                values[col] = gval;
                                                                break;
 
                                                        case G_TYPE_DOUBLE:
-                                                               g_value_set_double (&gval, gdaex_data_model_iter_get_value_double_at (gda_iter, col));
+                                                               if (col_missings[col])
+                                                                       {
+                                                                               g_value_set_double (&gval, 0.0);
+                                                                       }
+                                                               else
+                                                                       {
+                                                                               g_value_set_double (&gval, gdaex_data_model_iter_get_value_double_at (gda_iter, col));
+                                                                       }
                                                                values[col] = gval;
                                                                break;
 
                                                        case G_TYPE_BOOLEAN:
-                                                               g_value_set_boolean (&gval, gdaex_data_model_iter_get_value_boolean_at (gda_iter, col));
+                                                               if (col_missings[col])
+                                                                       {
+                                                                               g_value_set_boolean (&gval, FALSE);
+                                                                       }
+                                                               else
+                                                                       {
+                                                                               g_value_set_boolean (&gval, gdaex_data_model_iter_get_value_boolean_at (gda_iter, col));
+                                                                       }
                                                                values[col] = gval;
                                                                break;
 
@@ -2924,9 +2976,34 @@ gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
                                }
 
                        gtk_list_store_set_valuesv (lstore, &iter, columns, values, cols);
+                       if (call_missing_func
+                           && missing_func != NULL)
+                               {
+                                       missing_func (lstore, &iter, user_data);
+                               }
                }
 }
 
+void
+gdaex_fill_liststore_from_sql (GdaEx *gdaex,
+                               GtkListStore *lstore,
+                               const gchar *sql,
+                               guint *cols_formatted,
+                               gchar *(*cols_format_func) (GdaDataModelIter *, guint))
+{
+       gdaex_fill_liststore_from_sql_with_missing_func (gdaex, lstore, sql, cols_formatted, cols_format_func, NULL, NULL);
+}
+
+void
+gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
+                                     GtkListStore *lstore,
+                                     GdaDataModel *dm,
+                                     guint *cols_formatted,
+                                     gchar *(*cols_format_func) (GdaDataModelIter *, guint))
+{
+       gdaex_fill_liststore_from_datamodel_with_missing_func (gdaex, lstore, dm, cols_formatted, cols_format_func, NULL, NULL);
+}
+
 gchar
 *gdaex_format_money (gdouble number,
                      gint decimals,
index 39a8b3981a95db6f9134e44bbe99f29a16bcf1ad..8740a05f133981ce76e9f4b454a830d2dc632278 100644 (file)
@@ -200,12 +200,30 @@ const gchar *gdaex_get_guifile (GdaEx *gdaex);
 
 GtkBuilder *gdaex_get_gtkbuilder (GdaEx *gdaex);
 
-void gdaex_fill_liststore_from_sql (GdaEx *gdaex, GtkListStore *lstore, const gchar *sql,
-                                     guint *cols_formatted,
-                                     gchar *(*cols_format_func) (GdaDataModelIter *, guint));
-void gdaex_fill_liststore_from_datamodel (GdaEx *gdaex, GtkListStore *lstore, GdaDataModel *dm,
-                                     guint *cols_formatted,
-                                     gchar *(*cols_format_func) (GdaDataModelIter *, guint));
+typedef void (*GdaExFillListStoreMissingFunc) (GtkListStore *lstore, GtkTreeIter *iter, gpointer user_data);
+
+void gdaex_fill_liststore_from_sql_with_missing_func (GdaEx *gdaex,
+                                                      GtkListStore *lstore,
+                                                      const gchar *sql,
+                                                      guint *cols_formatted,
+                                                      gchar *(*cols_format_func) (GdaDataModelIter *, guint),
+                                                      GdaExFillListStoreMissingFunc missing_func, gpointer user_data);
+void gdaex_fill_liststore_from_datamodel_with_missing_func (GdaEx *gdaex,
+                                                            GtkListStore *lstore,
+                                                            GdaDataModel *dm,
+                                                            guint *cols_formatted,
+                                                            gchar *(*cols_format_func) (GdaDataModelIter *, guint),
+                                                            GdaExFillListStoreMissingFunc missing_func, gpointer user_data);
+void gdaex_fill_liststore_from_sql (GdaEx *gdaex,
+                                    GtkListStore *lstore,
+                                    const gchar *sql,
+                                    guint *cols_formatted,
+                                    gchar *(*cols_format_func) (GdaDataModelIter *, guint));
+void gdaex_fill_liststore_from_datamodel (GdaEx *gdaex,
+                                          GtkListStore *lstore,
+                                          GdaDataModel *dm,
+                                          guint *cols_formatted,
+                                          gchar *(*cols_format_func) (GdaDataModelIter *, guint));
 
 gchar *gdaex_format_money (gdouble number,
                      gint decimals,