]> saetta.ns0.it Git - libgdaex/commitdiff
QueryEditor: added and implemented where_default_not and where_default_type field...
authorAndrea Zagli <andrea.zagli@email.it>
Sat, 5 Mar 2016 11:33:06 +0000 (12:33 +0100)
committerAndrea Zagli <andrea.zagli@email.it>
Sat, 5 Mar 2016 11:33:06 +0000 (12:33 +0100)
data/gdaex_query_editor.dtd
src/queryeditor.c
src/queryeditor.h
tests/query_editor.xml

index 238b889caeaece22be511b59ded3a779d8c4e569..b5011e0fc05513b735e976309053938597255af2 100644 (file)
@@ -13,7 +13,7 @@
        table_name CDATA #REQUIRED
 >
 
-<!ELEMENT field (name, name_visible?, description?, alias?, type, for_show, always_showed, for_where, available_where_type, for_order, always_ordered, order_default, decode)>
+<!ELEMENT field (name, name_visible?, description?, alias?, type, for_show, always_showed, for_where, available_where_type, where_default_not, where_default_type, for_order, always_ordered, order_default, decode)>
 
 <!ELEMENT table_name (#PCDATA)>
 <!ELEMENT name_visible (#PCDATA)>
@@ -24,6 +24,8 @@
 <!ELEMENT always_showed (#PCDATA)>
 <!ELEMENT for_where (#PCDATA)>
 <!ELEMENT available_where_type (#PCDATA)>
+<!ELEMENT where_default_not (#PCDATA)>
+<!ELEMENT where_default_type (#PCDATA)>
 <!ELEMENT for_order (#PCDATA)>
 <!ELEMENT always_ordered (#PCDATA)>
 <!ELEMENT order_default (#PCDATA)>
index 2b92ac382be1ec6d62b21bc8cdf2bcbfc8d8ac9e..9d485f366b0f6047d012bb67b171cc38cd4cdd00 100644 (file)
@@ -1382,6 +1382,14 @@ gdaex_query_editor_load_tables_from_xml (GdaExQueryEditor *qe,
                                                                                                {
                                                                                                        field->available_where_type = gdaex_query_editor_str_to_where_type (xmlNodeGetContent (cur));
                                                                                                }
+                                                                                       else if (xmlStrcmp (cur->name, "where_default_not") == 0)
+                                                                                               {
+                                                                                                       field->where_default_not = zak_utils_string_to_boolean (xmlNodeGetContent (cur));
+                                                                                               }
+                                                                                       else if (xmlStrcmp (cur->name, "where_default_type") == 0)
+                                                                                               {
+                                                                                                       field->where_default_type = gdaex_query_editor_str_to_where_type (xmlNodeGetContent (cur));
+                                                                                               }
                                                                                        else if (xmlStrcmp (cur->name, "for_order") == 0)
                                                                                                {
                                                                                                        field->for_order = zak_utils_string_to_boolean (xmlNodeGetContent (cur));
@@ -3714,6 +3722,7 @@ gdaex_query_editor_on_btn_save_clicked (GtkButton *button,
        val1 = NULL;
        val2 = NULL;
        asc_desc = NULL;
+       asc_desc_visible = NULL;
 
        switch (priv->editor_type)
                {
@@ -3872,8 +3881,10 @@ gdaex_query_editor_on_btn_save_clicked (GtkButton *button,
                                                else
                                                        {
                                                                where_type = 0;
+                                                               val1_visible = g_strdup ("");
                                                                val1 = g_strdup ("");
                                                                val1_sql = g_strdup ("");
+                                                               val2_visible = g_strdup ("");
                                                                val2 = g_strdup ("");
                                                                val2_sql = g_strdup ("");
                                                        }
@@ -3894,7 +3905,9 @@ gdaex_query_editor_on_btn_save_clicked (GtkButton *button,
 
                                                gtk_tree_selection_unselect_all (priv->sel_where);
 
+                                               g_free (val1_visible);
                                                g_free (val1_sql);
+                                               g_free (val2_visible);
                                                g_free (val2_sql);
                                        }
                                break;
@@ -4200,7 +4213,7 @@ gdaex_query_editor_on_sel_show_changed (GtkTreeSelection *treeselection,
 
 static void
 gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button,
-                                    gpointer user_data)
+                                                                                        gpointer user_data)
 {
        GdaExQueryEditor *qe;
        GdaExQueryEditorPrivate *priv;
@@ -4258,6 +4271,9 @@ gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button,
                                            COL_WHERE_TABLE_NAME, field->table_name,
                                            COL_WHERE_NAME, field_name,
                                            COL_WHERE_VISIBLE_NAME, g_strconcat (table->name_visible, " - ", field->name_visible, NULL),
+                                                               COL_WHERE_CONDITION_NOT, field->where_default_not,
+                                                               COL_WHERE_CONDITION_TYPE, field->where_default_type,
+                                                               COL_WHERE_CONDITION_TYPE_VISIBLE, gdaex_query_editor_get_where_type_str_from_type (field->where_default_type),
                                            -1);
 
                        if (with_parent)
@@ -4460,7 +4476,6 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection,
                        if (GTK_IS_BOX (priv->hbox_where))
                                {
                                        gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->cb_link_type), NULL);
-                                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->chk_not), not);
                                        gtk_container_remove (GTK_CONTAINER (priv->tbl), GTK_WIDGET (priv->txt_from));
                                        gtk_container_remove (GTK_CONTAINER (priv->tbl), GTK_WIDGET (priv->txt_to));
                                }
@@ -4541,6 +4556,8 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection,
                                        gtk_grid_attach (GTK_GRID (priv->tbl), priv->lbl_to, 5, 1, 1, 1);
                                }
 
+                       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->chk_not), not);
+
                        if (is_group)
                                {
                                        gtk_label_set_label (GTK_LABEL (gtk_frame_get_label_widget (GTK_FRAME (priv->frame_where))), "");
@@ -4632,9 +4649,9 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection,
                                                {
                                                        gtk_list_store_append (priv->lstore_where_type, &iter_cb);
                                                        gtk_list_store_set (priv->lstore_where_type, &iter_cb,
-                                                           0, GDAEX_QE_WHERE_TYPE_ICONTAINS,
-                                                           1, gdaex_query_editor_get_where_type_str_from_type (GDAEX_QE_WHERE_TYPE_ICONTAINS),
-                                                           -1);
+                                                                                               0, GDAEX_QE_WHERE_TYPE_ICONTAINS,
+                                                                                               1, gdaex_query_editor_get_where_type_str_from_type (GDAEX_QE_WHERE_TYPE_ICONTAINS),
+                                                                                               -1);
                                                }
                                        if (field->available_where_type & GDAEX_QE_WHERE_TYPE_IENDS)
                                                {
@@ -4771,8 +4788,6 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection,
                                        gtk_widget_set_visible (gtk_frame_get_label_widget (GTK_FRAME (priv->frame_where)), TRUE);
                                        gtk_widget_set_visible (priv->lbl_where_type, TRUE);
                                        gtk_widget_set_visible (priv->cb_where_type, TRUE);
-                                       gtk_widget_set_visible (priv->lbl_from, TRUE);
-                                       gtk_widget_set_visible (priv->txt_from, TRUE);
                                }
                        else
                                {
index cdefb8f27d15b5bd1034e95ccc861db5d1d3e6f9..d92890fe327e204ff59e8ba77cc6cf1dfcf5ca6d 100644 (file)
@@ -127,6 +127,8 @@ typedef struct
                gboolean always_showed;
                gboolean for_where;
                guint available_where_type;
+               gboolean where_default_not;
+               GdaExQueryEditorWhereType where_default_type;
                gboolean for_order;
                gboolean always_ordered;
                GdaExQueryEditorOrderType order_default;
index 5096f61b53643563eed70f21be051a5861dbfbfc..bced065481a45a208369b4e7667f744925c30ee0 100644 (file)
@@ -32,6 +32,8 @@
                        <description>The client's surname</description>
                        <type>text</type>
                        <available_where_type>string|is_null</available_where_type>
+                       <where_default_not>t</where_default_not>
+                       <where_default_type>is_null</where_default_type>
                        <always_ordered>true</always_ordered>
                        <order_default>DESC</order_default>
                </field>