From: Andrea Zagli Date: Sun, 27 Nov 2011 10:35:54 +0000 (+0100) Subject: In GdaExQueryEditor started groups (parenthesis). X-Git-Tag: 0.5.0~14^2~2 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=a1f703b748fa1712d25c665447bc71a9900f2b7b;p=libgdaex In GdaExQueryEditor started groups (parenthesis). --- diff --git a/.anjuta/session/anjuta.session b/.anjuta/session/anjuta.session index 9954397..5319aca 100644 --- a/.anjuta/session/anjuta.session +++ b/.anjuta/session/anjuta.session @@ -4,11 +4,11 @@ Maximized=1 Geometry=1366x745+0+1 [Project Manager] -Shortcut=libgdaex//libgdaex//src//libgdaex.la%%%libgdaex//libgdaex//tests//grid%%%libgdaex//libgdaex//tests//query_editor%%%libgdaex//libgdaex//tests//select%%%libgdaex//libgdaex//tests//test_prefix -Expand=libgdaex.la%%%libgdaex +Shortcut=libgdaex//libgdaex//src//libgdaex.la%%%libgdaex//libgdaex//tests//fill_liststore%%%libgdaex//libgdaex//tests//grid%%%libgdaex//libgdaex//tests//query_editor%%%libgdaex//libgdaex//tests//select%%%libgdaex//libgdaex//tests//test_prefix +Expand=libgdaex.la [File Loader] -Files=file:///home/andreaz/files/c/libgdaex/src/queryeditor.c#668 +Files=file:///home/andreaz/files/c/libgdaex/src/gdaex.c#2780 [Document Manager] bookmarks=\n\n diff --git a/.anjuta/session/dock-layout.xml b/.anjuta/session/dock-layout.xml index 17c0817..44849a9 100644 --- a/.anjuta/session/dock-layout.xml +++ b/.anjuta/session/dock-layout.xml @@ -1,2 +1,2 @@ - + diff --git a/.anjuta_sym_db.db b/.anjuta_sym_db.db index 6526f20..6591671 100644 Binary files a/.anjuta_sym_db.db and b/.anjuta_sym_db.db differ diff --git a/data/libgdaex/gui/libgdaex.ui b/data/libgdaex/gui/libgdaex.ui index d32342e..c5e508f 100644 --- a/data/libgdaex/gui/libgdaex.ui +++ b/data/libgdaex/gui/libgdaex.ui @@ -292,6 +292,7 @@ True tstore_where False + treeviewcolumn5 True 4 @@ -390,6 +391,21 @@ 0 + + + Add gr_oup + False + True + True + True + True + + + False + False + 1 + + gtk-remove @@ -402,7 +418,7 @@ False False - 1 + 2 @@ -417,7 +433,7 @@ False False - 2 + 3 @@ -432,7 +448,7 @@ False False - 3 + 4 @@ -447,7 +463,7 @@ False False - 4 + 5 diff --git a/po/it.po b/po/it.po index 255b8fe..71feb3b 100644 --- a/po/it.po +++ b/po/it.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libgdaex 0.4.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-11-23 18:27+0100\n" +"POT-Creation-Date: 2011-11-27 11:27+0100\n" "PO-Revision-Date: 2011-10-24 17:44+0200\n" "Last-Translator: Andrea Zagli \n" "Language-Team: Italian \n" @@ -33,14 +33,14 @@ msgid "Error creating database connection: %s" msgstr "Errore nella creazione della connessione al database: %s" #: ../src/gdaex.c:286 ../src/gdaex.c:689 ../src/gdaex.c:706 -#: ../src/gdaex.c:1028 ../src/gdaex.c:1068 ../src/gdaex.c:1107 -#: ../src/gdaex.c:1146 ../src/gdaex.c:1198 ../src/gdaex.c:1293 -#: ../src/gdaex.c:1353 ../src/gdaex.c:1419 ../src/gdaex.c:1469 -#: ../src/gdaex.c:2295 ../src/gdaex.c:2405 ../src/gdaex.c:2452 -#: ../src/gdaex.c:2470 ../src/gdaex.c:2523 ../src/gdaex.c:2582 -#: ../src/gdaex.c:2635 ../src/gdaex.c:2923 ../src/gdaex.c:2941 -#: ../src/queryeditor.c:350 ../src/queryeditor.c:1260 -#: ../src/queryeditor.c:1272 +#: ../src/gdaex.c:1041 ../src/gdaex.c:1081 ../src/gdaex.c:1120 +#: ../src/gdaex.c:1159 ../src/gdaex.c:1211 ../src/gdaex.c:1306 +#: ../src/gdaex.c:1366 ../src/gdaex.c:1432 ../src/gdaex.c:1482 +#: ../src/gdaex.c:2308 ../src/gdaex.c:2418 ../src/gdaex.c:2465 +#: ../src/gdaex.c:2483 ../src/gdaex.c:2536 ../src/gdaex.c:2595 +#: ../src/gdaex.c:2648 ../src/gdaex.c:2951 ../src/gdaex.c:2969 +#: ../src/queryeditor.c:366 ../src/queryeditor.c:1350 +#: ../src/queryeditor.c:1362 msgid "no details" msgstr "nessun dettaglio" @@ -95,19 +95,19 @@ msgstr "" msgid "Selection query executed: %s" msgstr "Query di selezione eseguita: %s" -#: ../src/gdaex.c:744 ../src/gdaex.c:775 ../src/gdaex.c:805 ../src/gdaex.c:835 -#: ../src/gdaex.c:865 ../src/gdaex.c:895 ../src/gdaex.c:926 ../src/gdaex.c:957 -#: ../src/gdaex.c:988 ../src/gdaex.c:1500 ../src/gdaex.c:1532 -#: ../src/gdaex.c:1563 ../src/gdaex.c:1594 ../src/gdaex.c:1625 -#: ../src/gdaex.c:1656 ../src/gdaex.c:1688 ../src/gdaex.c:1720 -#: ../src/gdaex.c:1752 +#: ../src/gdaex.c:757 ../src/gdaex.c:788 ../src/gdaex.c:818 ../src/gdaex.c:848 +#: ../src/gdaex.c:878 ../src/gdaex.c:908 ../src/gdaex.c:939 ../src/gdaex.c:970 +#: ../src/gdaex.c:1001 ../src/gdaex.c:1513 ../src/gdaex.c:1545 +#: ../src/gdaex.c:1576 ../src/gdaex.c:1607 ../src/gdaex.c:1638 +#: ../src/gdaex.c:1669 ../src/gdaex.c:1701 ../src/gdaex.c:1733 +#: ../src/gdaex.c:1765 #, c-format msgid "No column found with name «%s»." msgstr "Nessuna colonna trovata con il nome «%s»." -#: ../src/gdaex.c:1026 ../src/gdaex.c:1066 ../src/gdaex.c:1105 -#: ../src/gdaex.c:1144 ../src/gdaex.c:1196 ../src/gdaex.c:1291 -#: ../src/gdaex.c:1351 ../src/gdaex.c:1417 ../src/gdaex.c:1467 +#: ../src/gdaex.c:1039 ../src/gdaex.c:1079 ../src/gdaex.c:1118 +#: ../src/gdaex.c:1157 ../src/gdaex.c:1209 ../src/gdaex.c:1304 +#: ../src/gdaex.c:1364 ../src/gdaex.c:1430 ../src/gdaex.c:1480 #, c-format msgid "" "Error on retrieving field's value: «%s».\n" @@ -116,7 +116,7 @@ msgstr "" "Errore nell'ottenere il valore del campo: «%s»\n" "%s\n" -#: ../src/gdaex.c:1284 ../src/gdaex.c:1344 ../src/gdaex.c:1410 +#: ../src/gdaex.c:1297 ../src/gdaex.c:1357 ../src/gdaex.c:1423 #, c-format msgid "" "Error on retrieving field's value: «%s».\n" @@ -125,40 +125,40 @@ msgstr "" "Errore nell'ottenere il valore del campo: «%s».\n" "Tipo GValue sconosciuto." -#: ../src/gdaex.c:1779 ../src/gdaex.c:1817 ../src/gdaex.c:1855 -#: ../src/gdaex.c:1893 ../src/gdaex.c:1931 ../src/gdaex.c:1984 -#: ../src/gdaex.c:2077 ../src/gdaex.c:2135 ../src/gdaex.c:2195 +#: ../src/gdaex.c:1792 ../src/gdaex.c:1830 ../src/gdaex.c:1868 +#: ../src/gdaex.c:1906 ../src/gdaex.c:1944 ../src/gdaex.c:1997 +#: ../src/gdaex.c:2090 ../src/gdaex.c:2148 ../src/gdaex.c:2208 #, c-format msgid "Error on retrieving field's value: «%s»." msgstr "Errore nell'ottenere il valore del campo: «%s»." -#: ../src/gdaex.c:2046 ../src/gdaex.c:2102 ../src/gdaex.c:2166 +#: ../src/gdaex.c:2059 ../src/gdaex.c:2115 ../src/gdaex.c:2179 msgid "Error on retrieving field's value: unknown GValue type." msgstr "Impossibile ottenere il valore del campo: tipo GValue sconosciuto." -#: ../src/gdaex.c:2293 +#: ../src/gdaex.c:2306 #, c-format msgid "Error on retrieving column %d: %s" msgstr "Errore nell'ottenere la colonna %d: %s" -#: ../src/gdaex.c:2343 +#: ../src/gdaex.c:2356 msgid "Invalid GdaDataModel." msgstr "GdaDataModel non valido." -#: ../src/gdaex.c:2357 +#: ../src/gdaex.c:2370 msgid "Unable to create the GtkTreeModel." msgstr "Impossibile creare il GtkTreeModel." -#: ../src/gdaex.c:2404 +#: ../src/gdaex.c:2417 #, c-format msgid "Error opening transaction: %s\n" msgstr "Errore nell'apertura della transazione: %s\n" -#: ../src/gdaex.c:2411 +#: ../src/gdaex.c:2424 msgid "Transaction opened." msgstr "Transazione aperta." -#: ../src/gdaex.c:2445 +#: ../src/gdaex.c:2458 #, c-format msgid "" "REMAINS:\n" @@ -171,7 +171,7 @@ msgstr "" "da\n" "%s" -#: ../src/gdaex.c:2451 ../src/gdaex.c:2522 +#: ../src/gdaex.c:2464 ../src/gdaex.c:2535 #, c-format msgid "" "Error parsing sql: %s\n" @@ -180,7 +180,7 @@ msgstr "" "Errore nell'analisi dell'sql: %s\n" "%s" -#: ../src/gdaex.c:2469 +#: ../src/gdaex.c:2482 #, c-format msgid "" "Error executing command query: %s\n" @@ -189,235 +189,243 @@ msgstr "" "Errore nell'esecuzione della query di comando: %s\n" "%s" -#: ../src/gdaex.c:2477 +#: ../src/gdaex.c:2490 #, c-format msgid "Query executed: %s" msgstr "Query eseguita: %s" -#: ../src/gdaex.c:2571 ../src/gdaex.c:2624 +#: ../src/gdaex.c:2584 ../src/gdaex.c:2637 msgid "No transaction opened." msgstr "Nessuna transazione aperta." -#: ../src/gdaex.c:2581 +#: ../src/gdaex.c:2594 #, c-format msgid "Error committing transaction: %s" msgstr "Errore nel committare la transazione: %s" -#: ../src/gdaex.c:2589 +#: ../src/gdaex.c:2602 msgid "Transaction committed." msgstr "Transazione committata." -#: ../src/gdaex.c:2634 +#: ../src/gdaex.c:2647 #, c-format msgid "Error rollbacking transaction: %s" msgstr "Errore nel rollbacking della transazione: %s" -#: ../src/gdaex.c:2642 +#: ../src/gdaex.c:2655 msgid "Transaction rolled back." msgstr "Transazione rolled back." -#: ../src/gdaex.c:2922 +#: ../src/gdaex.c:2950 #, c-format msgid "Error on creating regex: %s" msgstr "Errore nella creazione dell'espressione regolare: %s" -#: ../src/gdaex.c:2940 +#: ../src/gdaex.c:2968 #, c-format msgid "Error on regex replacing: %s" msgstr "Errore nell'espressione regolare di sostituzione: %s" -#: ../src/queryeditor.c:349 +#: ../src/queryeditor.c:365 #, c-format msgid "Error on gui initialization: %s." msgstr "Errore nell'inizializzazione dell'interfaccia grafica: %s." -#: ../src/queryeditor.c:581 ../src/queryeditor.c:673 ../src/queryeditor.c:681 +#: ../src/queryeditor.c:601 ../src/queryeditor.c:763 ../src/queryeditor.c:771 #, c-format msgid "Table «%s» doesn't exists." msgstr "La tabella «%s» non esiste." -#: ../src/queryeditor.c:590 ../src/queryeditor.c:598 +#: ../src/queryeditor.c:610 ../src/queryeditor.c:618 msgid "No field added: the field must have a name." msgstr "Nessun campo aggiunto: il campo deve avere un nome." -#: ../src/queryeditor.c:717 +#: ../src/queryeditor.c:807 msgid "Relation not created: no field added to the relation." msgstr "Relazione non creata: nesuun campo aggiunto alla relazione." -#: ../src/queryeditor.c:1182 ../src/queryeditor.c:1575 +#: ../src/queryeditor.c:1272 ../src/queryeditor.c:1665 #, c-format msgid "Where type «%d» not valid." msgstr "Tipo where «%d» non valido." -#: ../src/queryeditor.c:1259 +#: ../src/queryeditor.c:1349 #, c-format msgid "Unable to create GdaStatement: %s." msgstr "Impossibile creare l'oggetto GdaStatement: %s." -#: ../src/queryeditor.c:1271 +#: ../src/queryeditor.c:1361 #, c-format msgid "Unable to create sql: %s." msgstr "Impossibile creare l'sql: %s." -#: ../src/queryeditor.c:1510 +#: ../src/queryeditor.c:1600 #, c-format msgid "Link type «%d» not valid." msgstr "Tipo collegamento «%d» non valido." -#: ../src/queryeditor.c:1670 +#: ../src/queryeditor.c:1760 #, c-format msgid "Table «%s» not found." msgstr "Tabella «%s» non trovata." -#: ../src/queryeditor.c:1678 +#: ../src/queryeditor.c:1768 #, c-format msgid "Field «%s» not found in table «%s»." msgstr "Campo «%s» non trovato nella tabella «%s»." -#: ../src/queryeditor.c:1865 ../src/queryeditor.c:2725 +#: ../src/queryeditor.c:1955 ../src/queryeditor.c:2815 msgid "ASC" msgstr "ASC" -#: ../src/queryeditor.c:1866 ../src/queryeditor.c:2729 +#: ../src/queryeditor.c:1956 ../src/queryeditor.c:2819 msgid "DESC" msgstr "DISC" -#: ../src/queryeditor.c:2117 +#: ../src/queryeditor.c:2207 msgid "Are you sure you want to remove the selected field?" msgstr "Eliminare il campo selezionato?" -#: ../src/queryeditor.c:2138 ../src/queryeditor.c:2234 -#: ../src/queryeditor.c:2803 ../src/queryeditor.c:2974 -#: ../src/queryeditor.c:3441 +#: ../src/queryeditor.c:2228 ../src/queryeditor.c:2324 +#: ../src/queryeditor.c:2893 ../src/queryeditor.c:3095 +#: ../src/queryeditor.c:3606 msgid "You must select a field before." msgstr "Occorre prima selezione un campo." -#: ../src/queryeditor.c:2296 +#: ../src/queryeditor.c:2386 msgid "Equal" msgstr "uguale a" -#: ../src/queryeditor.c:2300 +#: ../src/queryeditor.c:2390 msgid "Starts with" msgstr "inizia per" -#: ../src/queryeditor.c:2304 +#: ../src/queryeditor.c:2394 msgid "Contains" msgstr "contiene" -#: ../src/queryeditor.c:2308 +#: ../src/queryeditor.c:2398 msgid "Ends with" msgstr "finisce con" -#: ../src/queryeditor.c:2312 +#: ../src/queryeditor.c:2402 msgid "Case-insensitive starts with" msgstr "inizia per (no maiuscole/minuscole)" -#: ../src/queryeditor.c:2316 +#: ../src/queryeditor.c:2406 msgid "Case-insensitive contains" msgstr "contiene (no maiuscole/minuscole)" -#: ../src/queryeditor.c:2320 +#: ../src/queryeditor.c:2410 msgid "Case-insensitive ends with" msgstr "finisce con (no maiuscole/minuscole)" -#: ../src/queryeditor.c:2324 +#: ../src/queryeditor.c:2414 msgid "Greater" msgstr "maggiore di" -#: ../src/queryeditor.c:2328 +#: ../src/queryeditor.c:2418 msgid "Greater or equal" msgstr "maggiore di o uguale a" -#: ../src/queryeditor.c:2332 +#: ../src/queryeditor.c:2422 msgid "Lesser" msgstr "minore di" -#: ../src/queryeditor.c:2336 +#: ../src/queryeditor.c:2426 msgid "Lesser or equal" msgstr "minore di o uguale a" -#: ../src/queryeditor.c:2340 +#: ../src/queryeditor.c:2430 msgid "Between" msgstr "compreso tra" -#: ../src/queryeditor.c:2344 +#: ../src/queryeditor.c:2434 msgid "Is NULL" msgstr "è NULL" -#: ../src/queryeditor.c:2361 +#: ../src/queryeditor.c:2451 msgid "And" msgstr "e" -#: ../src/queryeditor.c:2365 +#: ../src/queryeditor.c:2455 msgid "Or" msgstr "o" -#: ../src/queryeditor.c:2631 +#: ../src/queryeditor.c:2721 msgid "You must select a link's type before." msgstr "Occorre selezionare prima un tipo di collegamento." -#: ../src/queryeditor.c:2653 +#: ../src/queryeditor.c:2743 msgid "You must select a condition's type before." msgstr "Occorre selezionare prima un tipo di condizione." #. if it is the first condition, "link" isn't visibile -#: ../src/queryeditor.c:3106 ../data/libgdaex/gui/libgdaex.ui.h:6 +#: ../src/queryeditor.c:3269 ../data/libgdaex/gui/libgdaex.ui.h:7 msgid "Link" msgstr "Collegamento" -#: ../src/queryeditor.c:3110 ../data/libgdaex/gui/libgdaex.ui.h:7 +#: ../src/queryeditor.c:3273 ../data/libgdaex/gui/libgdaex.ui.h:8 msgid "Not" msgstr "Non" -#: ../src/queryeditor.c:3113 ../data/libgdaex/gui/libgdaex.ui.h:2 +#: ../src/queryeditor.c:3276 ../data/libgdaex/gui/libgdaex.ui.h:3 msgid "Condition" msgstr "Condizione" -#: ../src/queryeditor.c:3116 +#: ../src/queryeditor.c:3279 msgid "Value" msgstr "Valore" -#: ../src/queryeditor.c:3319 +#: ../src/queryeditor.c:3323 +msgid "and" +msgstr "e" + +#: ../src/queryeditor.c:3485 #, c-format msgid "Field's type «%d» not valid." msgstr "Il tipo campo «%d» non è valido." -#: ../src/queryeditor.c:3533 +#: ../src/queryeditor.c:3698 msgid "Ascending" msgstr "ascendente" -#: ../src/queryeditor.c:3536 +#: ../src/queryeditor.c:3701 msgid "Descending" msgstr "discendente" #: ../data/libgdaex/gui/libgdaex.ui.h:1 +msgid "Add gr_oup" +msgstr "Aggiungi gr_uppo" + +#: ../data/libgdaex/gui/libgdaex.ui.h:2 msgid "Alias" msgstr "Alias" -#: ../data/libgdaex/gui/libgdaex.ui.h:3 +#: ../data/libgdaex/gui/libgdaex.ui.h:4 msgid "Field" msgstr "Campo" -#: ../data/libgdaex/gui/libgdaex.ui.h:4 +#: ../data/libgdaex/gui/libgdaex.ui.h:5 msgid "Fields" msgstr "Campi" -#: ../data/libgdaex/gui/libgdaex.ui.h:5 +#: ../data/libgdaex/gui/libgdaex.ui.h:6 msgid "From" msgstr "da" -#: ../data/libgdaex/gui/libgdaex.ui.h:8 +#: ../data/libgdaex/gui/libgdaex.ui.h:9 msgid "Order" msgstr "Ordinamento" -#: ../data/libgdaex/gui/libgdaex.ui.h:9 +#: ../data/libgdaex/gui/libgdaex.ui.h:10 msgid "Show" msgstr "Mostra" -#: ../data/libgdaex/gui/libgdaex.ui.h:10 +#: ../data/libgdaex/gui/libgdaex.ui.h:11 msgid "To" msgstr "a" -#: ../data/libgdaex/gui/libgdaex.ui.h:11 +#: ../data/libgdaex/gui/libgdaex.ui.h:12 msgid "Where" msgstr "Condizioni" diff --git a/src/queryeditor.c b/src/queryeditor.c index 44c9182..34eb882 100644 --- a/src/queryeditor.c +++ b/src/queryeditor.c @@ -28,6 +28,8 @@ #include "queryeditor.h" #include "queryeditorentry.h" +#define GROUP "{--group--}" + typedef struct { gchar *name; @@ -133,6 +135,8 @@ static void gdaex_query_editor_on_sel_show_changed (GtkTreeSelection *treeselect static void gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button, gpointer user_data); +static void gdaex_query_editor_on_btn_where_add_group_clicked (GtkButton *button, + gpointer user_data); static void gdaex_query_editor_on_btn_where_remove_clicked (GtkButton *button, gpointer user_data); static void gdaex_query_editor_on_btn_where_up_clicked (GtkButton *button, @@ -184,6 +188,8 @@ struct _GdaExQueryEditorPrivate GtkWidget *vbx_values_container; GtkWidget *vbx_values; + GtkWidget *trv_where; + GtkTreeStore *tstore_fields; GtkListStore *lstore_show; GtkTreeStore *tstore_where; @@ -365,6 +371,8 @@ GdaExQueryEditor priv->notebook = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "notebook1")); + priv->trv_where = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "treeview3")); + priv->tstore_fields = GTK_TREE_STORE (gtk_builder_get_object (priv->gtkbuilder, "tstore_fields")); priv->lstore_show = GTK_LIST_STORE (gtk_builder_get_object (priv->gtkbuilder, "lstore_show")); priv->tstore_where = GTK_TREE_STORE (gtk_builder_get_object (priv->gtkbuilder, "tstore_where")); @@ -372,7 +380,7 @@ GdaExQueryEditor priv->sel_fields = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->gtkbuilder, "treeview1"))); priv->sel_show = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->gtkbuilder, "treeview2"))); - priv->sel_where = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->gtkbuilder, "treeview3"))); + priv->sel_where = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->trv_where)); priv->sel_order = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_builder_get_object (priv->gtkbuilder, "treeview4"))); priv->vbx_values_container = GTK_WIDGET (gtk_builder_get_object (priv->gtkbuilder, "vbox3")); @@ -403,6 +411,8 @@ GdaExQueryEditor g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button7"), "clicked", G_CALLBACK (gdaex_query_editor_on_btn_where_add_clicked), (gpointer)gdaex_query_editor); + g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button18"), "clicked", + G_CALLBACK (gdaex_query_editor_on_btn_where_add_group_clicked), (gpointer)gdaex_query_editor); g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button8"), "clicked", G_CALLBACK (gdaex_query_editor_on_btn_where_remove_clicked), (gpointer)gdaex_query_editor); g_signal_connect (gtk_builder_get_object (priv->gtkbuilder, "button9"), "clicked", @@ -3017,8 +3027,12 @@ gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button, GdaExQueryEditorPrivate *priv; GtkTreeIter iter; + GtkTreeIter iter_parent; GtkWidget *dialog; + gchar *group; + gboolean with_parent; + gchar *table_name; gchar *field_name; GdaExQueryEditorTable *table; @@ -3029,6 +3043,8 @@ gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button, if (gtk_tree_selection_get_selected (priv->sel_fields, NULL, &iter)) { + with_parent = FALSE; + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_fields), &iter, COL_FIELDS_TABLE_NAME, &table_name, COL_FIELDS_NAME, &field_name, @@ -3037,13 +3053,38 @@ gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button, table = g_hash_table_lookup (priv->tables, table_name); field = g_hash_table_lookup (table->fields, field_name); - gtk_tree_store_append (priv->tstore_where, &iter, NULL); + if (gtk_tree_selection_get_selected (priv->sel_where, NULL, &iter_parent)) + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_where), &iter_parent, + COL_WHERE_TABLE_NAME, &group, + -1); + if (g_strcmp0 (group, GROUP) != 0) + { + if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (priv->tstore_where), &iter, &iter_parent)) + { + with_parent = TRUE; + iter_parent = iter; + } + } + else + { + with_parent = TRUE; + } + } + + gtk_tree_store_append (priv->tstore_where, &iter, with_parent ? &iter_parent : NULL); gtk_tree_store_set (priv->tstore_where, &iter, 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), -1); + if (with_parent) + { + gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->trv_where), + gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tstore_where), &iter_parent)); + } + g_free (table_name); g_free (field_name); } @@ -3059,12 +3100,64 @@ gdaex_query_editor_on_btn_where_add_clicked (GtkButton *button, } } +static void +gdaex_query_editor_on_btn_where_add_group_clicked (GtkButton *button, + gpointer user_data) +{ + GdaExQueryEditor *qe; + GdaExQueryEditorPrivate *priv; + + GtkTreeIter iter_parent; + GtkTreeIter iter; + + gchar *group; + + qe = (GdaExQueryEditor *)user_data; + priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + + if (gtk_tree_selection_get_selected (priv->sel_where, NULL, &iter_parent)) + { + gtk_tree_model_get (GTK_TREE_MODEL (priv->tstore_where), &iter_parent, + COL_WHERE_TABLE_NAME, &group, + -1); + if (g_strcmp0 (group, GROUP) != 0) + { + if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (priv->tstore_where), &iter, &iter_parent)) + { + gtk_tree_store_append (priv->tstore_where, &iter, &iter); + } + else + { + gtk_tree_store_append (priv->tstore_where, &iter, NULL); + } + } + else + { + gtk_tree_store_append (priv->tstore_where, &iter, &iter_parent); + } + } + else + { + gtk_tree_store_append (priv->tstore_where, &iter, NULL); + } + gtk_tree_store_set (priv->tstore_where, &iter, + COL_WHERE_TABLE_NAME, GROUP, + COL_WHERE_NAME, GROUP, + COL_WHERE_VISIBLE_NAME, "( )", + -1); + gtk_tree_view_expand_to_path (GTK_TREE_VIEW (priv->trv_where), + gtk_tree_model_get_path (GTK_TREE_MODEL (priv->tstore_where), &iter)); +} + static void gdaex_query_editor_on_btn_where_remove_clicked (GtkButton *button, gpointer user_data) { - GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data; - GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + GdaExQueryEditor *qe; + GdaExQueryEditorPrivate *priv; + + qe = (GdaExQueryEditor *)user_data; + priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); gdaex_query_editor_store_remove_iter (qe, priv->sel_where, @@ -3075,8 +3168,11 @@ static void gdaex_query_editor_on_btn_where_up_clicked (GtkButton *button, gpointer user_data) { - GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data; - GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + GdaExQueryEditor *qe; + GdaExQueryEditorPrivate *priv; + + qe = (GdaExQueryEditor *)user_data; + priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); gdaex_query_editor_store_move_iter_up_down (qe, priv->sel_where, @@ -3088,8 +3184,11 @@ static void gdaex_query_editor_on_btn_where_down_clicked (GtkButton *button, gpointer user_data) { - GdaExQueryEditor *qe = (GdaExQueryEditor *)user_data; - GdaExQueryEditorPrivate *priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); + GdaExQueryEditor *qe; + GdaExQueryEditorPrivate *priv; + + qe = (GdaExQueryEditor *)user_data; + priv = GDAEX_QUERY_EDITOR_GET_PRIVATE (qe); gdaex_query_editor_store_move_iter_up_down (qe, priv->sel_where, @@ -3163,6 +3262,8 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, COL_WHERE_CONDITION_TO_SQL, &to_sql, -1); + if (g_strcmp0 (table_name, GROUP) == 0) return; + table = g_hash_table_lookup (priv->tables, table_name); field = g_hash_table_lookup (table->fields, field_name); @@ -3172,6 +3273,7 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, if (GTK_IS_HBOX (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->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)); } @@ -3223,10 +3325,11 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, lbl = gtk_label_new (g_strconcat (table->name_visible, " - ", field->name_visible, NULL)); gtk_table_attach (GTK_TABLE (priv->tbl), lbl, 1, 2, 1, 2, 0, 0, 0, 0); + /* not */ priv->not = gtk_check_button_new (); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->not), not); gtk_table_attach (GTK_TABLE (priv->tbl), priv->not, 2, 3, 1, 2, GTK_FILL, 0, 0, 0); + /* where */ priv->cb_where_type = gtk_combo_box_new_with_model (GTK_TREE_MODEL (priv->lstore_where_type)); renderer = gtk_cell_renderer_text_new (); @@ -3238,7 +3341,7 @@ gdaex_query_editor_on_sel_where_changed (GtkTreeSelection *treeselection, g_signal_connect (G_OBJECT (priv->cb_where_type), "changed", G_CALLBACK (gdaex_query_editor_on_cb_where_type_changed), user_data); - priv->lbl_to = gtk_label_new ("and"); + priv->lbl_to = gtk_label_new (_("and")); gtk_misc_set_alignment (GTK_MISC (priv->lbl_to), 1.0, 0.5); gtk_table_attach (GTK_TABLE (priv->tbl), priv->lbl_to, 3, 4, 2, 3, GTK_FILL, 0, 0, 0); }