}
}
- g_free (group);
+ return ret;
+}
+
+static GValue
+*zak_form_hashtable_provider_new_gvalue_from_element (ZakFormElement *element)
+{
+ GValue *ret;
+
+ gchar *value;
+ gchar *type;
+ GHashTable *format;
+
+ value = zak_form_element_get_value (element);
+ type = zak_form_element_get_provider_type (element);
+ format = zak_form_element_get_format (element);
+
+ if (g_ascii_strcasecmp (type, "integer") == 0)
+ {
+ gchar *thousands_saparator;
+ gdouble unformatted;
+
+ thousands_saparator = (gchar *)g_hash_table_lookup (format, "thousands_separator");
+
+ unformatted = zak_utils_unformat_money_full (value, thousands_saparator, NULL);
+
+ ret = zak_utils_gvalue_new_int ((gint)unformatted);
+ }
+ else if (g_ascii_strcasecmp (type, "float") == 0)
+ {
+ gchar *thousands_saparator;
+ gchar *currency_symbol;
+ gdouble unformatted;
+
+ thousands_saparator = (gchar *)g_hash_table_lookup (format, "thousands_separator");
+ currency_symbol = (gchar *)g_hash_table_lookup (format, "currency_symbol");
+
+ unformatted = zak_utils_unformat_money_full (value, thousands_saparator, currency_symbol);
+ ret = zak_utils_gvalue_new_float (unformatted);
+ }
+ else if (g_ascii_strcasecmp (type, "string") == 0)
+ {
+ ret = zak_utils_gvalue_new_string (value);
+ }
+ else if (g_ascii_strcasecmp (type, "boolean") == 0)
+ {
+ ret = zak_utils_gvalue_new_boolean (g_strcmp0 (value, "TRUE") == 0);
+ }
+ else if (g_ascii_strcasecmp (type, "date") == 0
+ || g_ascii_strcasecmp (type, "time") == 0
+ || g_ascii_strcasecmp (type, "datetime") == 0)
+ {
+ GDateTime *gdt;
+
+ gchar *datetime_format;
+
+ datetime_format = (gchar *)g_hash_table_lookup (format, "content");
+ gdt = zak_utils_get_gdatetime_from_string (value, datetime_format);
+
+ ret = zak_utils_gvalue_new_gdatetime (gdt);
+ }
return ret;
}
guint i;
- gchar *value;
GHashTable *group;
ZakFormHashtableProviderPrivate *priv = zak_form_hashtable_provider_get_instance_private (ZAK_FORM_HASHTABLE_PROVIDER (provider));
ZakFormElement *element = (ZakFormElement *)g_ptr_array_index (elements, i);
if (zak_form_element_get_to_save (element))
{
- value = zak_form_element_unformat (element, NULL);
-
g_hash_table_insert (group,
zak_form_element_get_name (element),
- value);
-
- g_free (value);
+ zak_form_hashtable_provider_new_gvalue_from_element (element));
}
}
- g_free (group);
-
return ret;
}
}
}
- g_free (group);
-
return ret;
}