<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
- <object class="GtkListStore" id="lstore_show">
- <columns>
- <!-- column-name table_name -->
- <column type="gchararray"/>
- <!-- column-name name -->
- <column type="gchararray"/>
- <!-- column-name name_visible -->
- <column type="gchararray"/>
- </columns>
- </object>
<object class="GtkTreeStore" id="tstore_where">
<columns>
<!-- column-name table_name -->
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkListStore" id="lstore_show">
+ <columns>
+ <!-- column-name table_name -->
+ <column type="gchararray"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name name_visible -->
+ <column type="gchararray"/>
+ <!-- column-name alias -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkWindow" id="w_query_editor">
<child>
<object class="GtkHPaned" id="hpaned_query_editor">
<property name="can_focus">True</property>
<property name="model">lstore_show</property>
<property name="headers_clickable">False</property>
- <property name="search_column">0</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">2</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn2">
<property name="title">Field</property>
</child>
</object>
</child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn10">
+ <property name="title">Alias</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext9"/>
+ <attributes>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
</object>
</child>
</object>
<property name="can_focus">True</property>
<property name="model">tstore_where</property>
<property name="headers_clickable">False</property>
- <property name="search_column">0</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">2</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
<property name="title">Field</property>
<property name="can_focus">True</property>
<property name="model">lstore_order</property>
<property name="headers_clickable">False</property>
- <property name="search_column">0</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">2</property>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="title">Field</property>
GSList *relations; /* GdaExQueryEditorRelation */
/* for value choosing */
- gboolean where_value;
+ guint editor_type; /* 1 - show; 2 - where; 3 - order */
+
GtkListStore *lstore_where_type;
GtkWidget *hbox;
GtkWidget *not;
{
COL_SHOW_TABLE_NAME,
COL_SHOW_NAME,
- COL_SHOW_VISIBLE_NAME
+ COL_SHOW_VISIBLE_NAME,
+ COL_SHOW_ALIAS
};
enum
gchar *table_name;
gchar *field_name;
+ gchar *alias;
gchar *asc_desc;
GdaExQueryEditorTable *table;
gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_show), &iter,
COL_SHOW_TABLE_NAME, &table_name,
COL_SHOW_NAME, &field_name,
+ COL_SHOW_ALIAS, &alias,
-1);
table = g_hash_table_lookup (priv->tables, table_name);
id_join1, id_join2, 0);
gda_sql_builder_select_join_targets (sqlbuilder, id_target1, id_target2,
GDA_SQL_SELECT_JOIN_INNER, join_cond);
- gda_sql_builder_select_add_field (sqlbuilder, field->decode_field_to_show, field->decode_table2, field->decode_field_alias);
+ gda_sql_builder_select_add_field (sqlbuilder, field->decode_field_to_show,
+ field->decode_table2,
+ alias != NULL && g_strcmp0 (alias, "") != 0 ? alias : field->decode_field_alias);
}
else
{
- gda_sql_builder_select_add_field (sqlbuilder, field->name, table->name, field->alias);
+ gda_sql_builder_select_add_field (sqlbuilder, field->name, table->name,
+ alias != NULL && g_strcmp0 (alias, "") != 0 ? alias : field->alias);
gda_sql_builder_select_add_target_id (sqlbuilder,
gda_sql_builder_add_id (sqlbuilder, table->name),
NULL);
gchar *table_name;
gchar *field_name;
+ GdaExQueryEditorTable *table;
+ GdaExQueryEditorField *field;
+
xmlNode *node;
ret = NULL;
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->lstore_show), &iter))
{
+ gchar *alias;
xmlNode *node_show;
node_show = xmlNewNode (NULL, "show");
gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_show), &iter,
COL_SHOW_TABLE_NAME, &table_name,
COL_SHOW_NAME, &field_name,
+ COL_SHOW_ALIAS, &alias,
-1);
+ table = g_hash_table_lookup (priv->tables, table_name);
+ field = g_hash_table_lookup (table->fields, field_name);
+
node = xmlNewNode (NULL, "field");
xmlAddChild (node_show, node);
xmlNewProp (node, "table", table_name);
xmlNewProp (node, "field", field_name);
+ if (alias != NULL && g_strcmp0 (alias, "") != 0)
+ {
+ xmlNewProp (node, "alias", alias);
+ }
+ else
+ {
+ xmlNewProp (node, "alias", field->alias);
+ }
} while (gtk_tree_model_iter_next (GTK_TREE_MODEL (priv->lstore_show), &iter));
}
gchar *table_name;
gchar *field_name;
gchar *name_visible;
+ gchar *alias;
GValue *v_table_field;
GdaExQueryEditorTable *table;
{
if (!gdaex_query_editor_model_has_value (GTK_TREE_MODEL (priv->lstore_show), COL_SHOW_VISIBLE_NAME, v_table_field))
{
+ alias = xmlGetProp (node_field, "alias");
+ if (alias == NULL)
+ {
+ alias = g_strdup ("");
+ }
+
gtk_list_store_append (priv->lstore_show, &iter);
gtk_list_store_set (priv->lstore_show, &iter,
COL_SHOW_TABLE_NAME, field->table_name,
COL_SHOW_NAME, field_name,
COL_SHOW_VISIBLE_NAME, name_visible,
+ COL_SHOW_ALIAS, alias,
-1);
}
}
gdaex_query_editor_remove_child_from_vbx_values (qe);
gtk_widget_hide (priv->vbx_values_container);
- if (priv->where_value)
+ switch (priv->editor_type)
{
- gtk_tree_selection_unselect_all (priv->sel_where);
- }
- else
- {
- gtk_tree_selection_unselect_all (priv->sel_order);
+ case 1:
+ gtk_tree_selection_unselect_all (priv->sel_show);
+ break;
+
+ case 2:
+ gtk_tree_selection_unselect_all (priv->sel_where);
+ break;
+
+ case 3:
+ gtk_tree_selection_unselect_all (priv->sel_order);
+ break;
}
}
GdaExQueryEditorPrivate *priv;
GtkTreeIter iter;
+
+ gchar *val1;
+ gchar *val2;
gchar *asc_desc;
qe = (GdaExQueryEditor *)user_data;
priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe);
- if (priv->where_value)
+ switch (priv->editor_type)
{
- if (gtk_tree_selection_get_selected (priv->sel_where, NULL, &iter))
- {
- GtkTreeIter iter_val;
- guint where_type;
+ case 1:
+ if (gtk_tree_selection_get_selected (priv->sel_show, NULL, &iter))
+ {
+ val1 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt1));
+ if (val1 == NULL)
+ {
+ val1 = g_strdup ("");
+ }
+ else
+ {
+ g_strstrip (val1);
+ }
+ gtk_list_store_set (priv->lstore_show, &iter,
+ COL_SHOW_ALIAS, val1,
+ -1);
+
+ gtk_tree_selection_unselect_all (priv->sel_show);
+ }
+ break;
+
+ case 2:
+ if (gtk_tree_selection_get_selected (priv->sel_where, NULL, &iter))
+ {
+ GtkTreeIter iter_val;
+ guint where_type;
- GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->cb_where_type));
- if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->cb_where_type), &iter_val))
- {
- GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)),
- GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_WARNING,
- GTK_BUTTONS_OK,
- "You must select a condition's type before.");
- gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);
- return;
- }
+ GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->cb_where_type));
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->cb_where_type), &iter_val))
+ {
+ GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (priv->hpaned_main)),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK,
+ "You must select a condition's type before.");
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ return;
+ }
- gtk_tree_model_get (model, &iter_val,
- 0, &where_type,
- -1);
+ gtk_tree_model_get (model, &iter_val,
+ 0, &where_type,
+ -1);
- gtk_tree_store_set (priv->tstore_where, &iter,
- COL_WHERE_CONDITION_NOT, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->not)),
- COL_WHERE_CONDITION_TYPE, where_type,
- COL_WHERE_CONDITION_TYPE_VISIBLE, gdaex_query_editor_get_where_type_str_from_type (where_type),
- COL_WHERE_CONDITION_FROM, gtk_entry_get_text (GTK_ENTRY (priv->txt1)),
- COL_WHERE_CONDITION_TO, priv->txt2 != NULL ? gtk_entry_get_text (GTK_ENTRY (priv->txt2)) : "",
- -1);
+ val1 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt1));
+ if (val1 == NULL)
+ {
+ val1 = g_strdup ("");
+ }
+ else
+ {
+ g_strstrip (val1);
+ }
- gtk_tree_selection_unselect_all (priv->sel_where);
- }
- }
- else
- {
- if (gtk_tree_selection_get_selected (priv->sel_order, NULL, &iter))
- {
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->opt_asc)))
- {
- asc_desc = g_strdup ("ASC");
- }
- else
- {
- asc_desc = g_strdup ("DESC");
- }
+ if (priv->txt2 != NULL)
+ {
+ val2 = (gchar *)gtk_entry_get_text (GTK_ENTRY (priv->txt2));
+ if (val2 == NULL)
+ {
+ val2 = g_strdup ("");
+ }
+ else
+ {
+ g_strstrip (val2);
+ }
+ }
+ else
+ {
+ val2 = g_strdup ("");
+ }
- gtk_list_store_set (priv->lstore_order, &iter,
- COL_ORDER_ORDER, asc_desc,
- -1);
+ gtk_tree_store_set (priv->tstore_where, &iter,
+ COL_WHERE_CONDITION_NOT, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->not)),
+ COL_WHERE_CONDITION_TYPE, where_type,
+ COL_WHERE_CONDITION_TYPE_VISIBLE, gdaex_query_editor_get_where_type_str_from_type (where_type),
+ COL_WHERE_CONDITION_FROM, val1,
+ COL_WHERE_CONDITION_TO, val2,
+ -1);
- gtk_tree_selection_unselect_all (priv->sel_order);
- }
+ gtk_tree_selection_unselect_all (priv->sel_where);
+ }
+ break;
+
+ case 3:
+ if (gtk_tree_selection_get_selected (priv->sel_order, NULL, &iter))
+ {
+ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->opt_asc)))
+ {
+ asc_desc = g_strdup ("ASC");
+ }
+ else
+ {
+ asc_desc = g_strdup ("DESC");
+ }
+
+ gtk_list_store_set (priv->lstore_order, &iter,
+ COL_ORDER_ORDER, asc_desc,
+ -1);
+
+ gtk_tree_selection_unselect_all (priv->sel_order);
+ }
+ break;
}
gtk_widget_hide (priv->vbx_values_container);
gchar *table_name;
gchar *field_name;
+ gchar *alias;
+
GdaExQueryEditorTable *table;
GdaExQueryEditorField *field;
+ GtkWidget *tbl;
+ GtkWidget *lbl;
+
GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data;
GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe);
+ gtk_widget_hide (priv->vbx_values_container);
+ gdaex_query_editor_remove_child_from_vbx_values (qe);
+
if (gtk_tree_selection_get_selected (priv->sel_show, NULL, &iter))
{
- gdaex_query_editor_remove_child_from_vbx_values (qe);
- gtk_widget_hide (priv->vbx_values_container);
+ priv->editor_type = 1;
gtk_tree_selection_unselect_all (priv->sel_where);
gtk_tree_selection_unselect_all (priv->sel_order);
gtk_tree_model_get (GTK_TREE_MODEL (priv->lstore_show), &iter,
COL_SHOW_TABLE_NAME, &table_name,
COL_SHOW_NAME, &field_name,
+ COL_SHOW_ALIAS, &alias,
-1);
table = g_hash_table_lookup (priv->tables, table_name);
field = g_hash_table_lookup (table->fields, field_name);
gtk_widget_set_sensitive (GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "button4")), !field->always_showed);
+
+ priv->hbox = gtk_hbox_new (TRUE, 0);
+
+ tbl = gtk_table_new (2, 2, FALSE);
+ gtk_table_set_row_spacings (GTK_TABLE (tbl), 5);
+ gtk_table_set_col_spacings (GTK_TABLE (tbl), 5);
+ gtk_box_pack_start (GTK_BOX (priv->hbox), tbl, TRUE, TRUE, 0);
+
+ lbl = gtk_label_new ("Alias");
+ gtk_table_attach (GTK_TABLE (tbl), lbl, 1, 2, 0, 1, 0, 0, 0, 0);
+
+ lbl = gtk_label_new (g_strconcat (table->name_visible, " - ", field->name_visible, NULL));
+ gtk_table_attach (GTK_TABLE (tbl), lbl, 0, 1, 1, 2, 0, 0, 0, 0);
+
+ priv->txt1 = gtk_entry_new ();
+ gtk_entry_set_text (GTK_ENTRY (priv->txt1), alias);
+ gtk_table_attach (GTK_TABLE (tbl), priv->txt1, 1, 2, 1, 2, 0, 0, 0, 0);
+
+ gtk_box_pack_start (GTK_BOX (priv->vbx_values), priv->hbox, FALSE, FALSE, 0);
+
+ gtk_widget_show_all (priv->vbx_values);
+ gtk_widget_show (priv->vbx_values_container);
}
}
if (gtk_tree_selection_get_selected (priv->sel_where, NULL, &iter))
{
- priv->where_value = TRUE;
+ priv->editor_type = 2;
gtk_tree_selection_unselect_all (priv->sel_show);
gtk_tree_selection_unselect_all (priv->sel_order);
if (gtk_tree_selection_get_selected (priv->sel_order, NULL, &iter))
{
- priv->where_value = FALSE;
+ priv->editor_type = 3;
gtk_tree_selection_unselect_all (priv->sel_show);
gtk_tree_selection_unselect_all (priv->sel_where);