From 0f6ddb8075ae9f4a907c4a6e6735efd08a0c6d88 Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Mon, 14 Jan 2019 11:38:38 -0300 Subject: [PATCH] restructuring and queries --- data/ui/query.1.ui | 61 ------- data/ui/query.gresource.xml | 2 +- data/ui/query.tree.ui | 168 +++++++++++++++++++ data/ui/query.window.ui | 1 + po/POTFILES | 2 +- po/es.po | 319 +++++++++++++++++++++--------------- po/sernatur.pot | 97 ++++++----- src/main_window.vala | 50 +++++- src/queries.vala | 40 ++++- src/query_window.vala | 208 ++++++++++++++++++++--- 10 files changed, 682 insertions(+), 266 deletions(-) delete mode 100644 data/ui/query.1.ui create mode 100644 data/ui/query.tree.ui diff --git a/data/ui/query.1.ui b/data/ui/query.1.ui deleted file mode 100644 index 3e41139..0000000 --- a/data/ui/query.1.ui +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - True - True - True - True - natural - natural - liststore1 - True - both - True - - - none - - - - - fixed - Region Name - - - - 0 - - - - - - - fixed - Quantity - - - - 1 - - - - - - diff --git a/data/ui/query.gresource.xml b/data/ui/query.gresource.xml index 722e564..5b464fc 100644 --- a/data/ui/query.gresource.xml +++ b/data/ui/query.gresource.xml @@ -15,6 +15,6 @@ query.window.ui - query.1.ui + query.tree.ui diff --git a/data/ui/query.tree.ui b/data/ui/query.tree.ui new file mode 100644 index 0000000..37ac7b3 --- /dev/null +++ b/data/ui/query.tree.ui @@ -0,0 +1,168 @@ + + + + + + + True + True + True + True + liststore1 + False + False + True + False + both + True + + + none + + + + + fixed + Region Name + + + + 0 + + + + + + + fixed + Quantity + + + + 1 + + + + + + + True + True + liststore1 + False + False + True + False + both + True + + + none + + + + + fixed + Tour Name + + + + + fixed + Total Value + + + + + True + True + liststore1 + False + False + True + False + both + True + + + none + + + + + fixed + Tour Name + + + + + fixed + Coordinator Total + + + + + True + True + liststore1 + False + False + True + False + both + True + + + none + + + + + fixed + Tour Name + + + + + fixed + Tourist Total + + + + + True + True + liststore1 + False + False + True + False + both + True + + + none + + + + + fixed + Percentage + + + + diff --git a/data/ui/query.window.ui b/data/ui/query.window.ui index 061e195..c5fcbcf 100644 --- a/data/ui/query.window.ui +++ b/data/ui/query.window.ui @@ -186,6 +186,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 5 5 5 + True diff --git a/po/POTFILES b/po/POTFILES index 57a76a4..6b7849f 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -32,6 +32,6 @@ data/ui/main.splash.ui data/ui/tour.list.ui data/ui/tour.editor.ui data/ui/query.window.ui -data/ui/query.1.ui +data/ui/query.tree.ui data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml diff --git a/po/es.po b/po/es.po index 746bad5..738d138 100644 --- a/po/es.po +++ b/po/es.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: sernatur\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-01-13 19:14-0300\n" -"PO-Revision-Date: 2019-01-13 19:15-0300\n" +"POT-Creation-Date: 2019-01-14 11:35-0300\n" +"PO-Revision-Date: 2019-01-14 11:37-0300\n" "Last-Translator: Chris Cromer \n" "Language-Team: none\n" "Language: es\n" @@ -20,15 +20,80 @@ msgstr "" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-Basepath: .\n" -#: data/ui/main.splash.ui:46 -msgid "Christopher Cromer" -msgstr "Christopher Cromer" +#: lib/db.vala:67 +msgid "Postgresql server version:" +msgstr "Versión del servidor Postgresql:" + +#: lib/dbwrapper.vala:138 +#, c-format +msgid "The field %s was not found in the query results!" +msgstr "La campo %s no estaba en los resultados de la consulta!" + +#: lib/misc.vala:138 +#, c-format +msgid "The RUT %s has an invalid character!" +msgstr "El RUT %s tiene un carácter invalido!" + +#: lib/misc.vala:154 +#, c-format +msgid "The RUT %s is too big!" +msgstr "El RUT %s es demasiado grande!" + +#: lib/misc.vala:159 +#, c-format +msgid "The verifier %C is invalid!" +msgstr "El verificador %C es invalido!" + +#: src/sernatur.vala:88 +#, c-format +msgid "Error: %s\n" +msgstr "Error %s\n" + +#: src/sernatur.vala:89 +#, c-format +msgid "" +"Run '%s --help' to see a full list of available command line options.\n" +msgstr "" +"Correr '%s --help' para ver una lista completa de las opciones de la " +"consola.\n" + +#: src/sernatur.vala:94 +msgid "SERNATUR version: " +msgstr "Versión de SERNATUR: " + +#: src/main_window.vala:216 +msgid "Error: Could not connect to the database!" +msgstr "Error: No se puede conectar al base de datos!" + +#: src/main_window.vala:228 +msgid "Error" +msgstr "Error" + +#: src/query_window.vala:232 data/ui/main.window.ui:143 +msgid "(Q1) Regions with discounts" +msgstr "(Q1) Regiones sin descuentos" + +#: src/query_window.vala:245 data/ui/main.window.ui:151 +msgid "(Q2) Tour values" +msgstr "(Q2) Valores tour" + +#: src/query_window.vala:258 data/ui/main.window.ui:159 +msgid "(Q3) Coordinator total" +msgstr "(Q3) Total de coordinadores" + +#: src/query_window.vala:271 data/ui/main.window.ui:167 +msgid "(Q4) Tourist total" +msgstr "(Q4) Total de turistas" + +#: src/query_window.vala:284 data/ui/main.window.ui:175 +msgid "(Q5) Vehicle total" +msgstr "(Q5) Total de vehículos" #: data/ui/main.window.ui:44 msgid "_Menu" msgstr "_Menú" -#: data/ui/main.window.ui:54 data/ui/query.window.ui:22 data/ui/tour.list.ui:22 +#: data/ui/main.window.ui:54 data/ui/tour.list.ui:23 msgid "Tours" msgstr "Tours" @@ -64,78 +129,67 @@ msgstr "Salir" msgid "_Views" msgstr "_Vistas" -#: data/ui/main.window.ui:143 -msgid "(Q1) Regions with discounts" -msgstr "(Q1) Regiones sin descuentos" +#: data/ui/main.splash.ui:46 +msgid "Christopher Cromer" +msgstr "Christopher Cromer" -#: data/ui/main.window.ui:151 -msgid "(Q2) Tour values" -msgstr "(Q2) Valores tour" +#: data/ui/tour.list.ui:68 data/ui/tour.editor.ui:54 data/ui/query.tree.ui:80 +#: data/ui/query.tree.ui:108 data/ui/query.tree.ui:136 +msgid "Tour Name" +msgstr "Nombre del Tour" -#: data/ui/main.window.ui:159 -msgid "(Q3) Coordinator total" -msgstr "(Q3) Total de coordinadores" +#: data/ui/tour.list.ui:82 data/ui/tour.editor.ui:87 +msgid "Individual Cost" +msgstr "Costo Individual" -#: data/ui/main.window.ui:167 -msgid "(Q4) Tourist total" -msgstr "(Q4) Total de turistas" +#: data/ui/tour.list.ui:96 data/ui/tour.editor.ui:103 +msgid "Group Cost" +msgstr "Costo Grupal" -#: data/ui/main.window.ui:175 -msgid "(Q5) Vehicle total" -msgstr "(Q5) Total de vehículos" +#: data/ui/tour.list.ui:110 data/ui/tour.editor.ui:119 +msgid "Minimum People" +msgstr "Mínima Personas" -#: data/ui/query.1.ui:37 -msgid "Region Name" -msgstr "Nombre de Región" +#: data/ui/tour.list.ui:124 data/ui/tour.editor.ui:187 +msgid "City" +msgstr "Ciudad" -#: data/ui/query.1.ui:49 -msgid "Quantity" -msgstr "Cantidad" +#: data/ui/tour.list.ui:138 data/ui/tour.editor.ui:135 +msgid "Region" +msgstr "Región" -#: data/ui/query.window.ui:67 data/ui/tour.list.ui:212 +#: data/ui/tour.list.ui:170 +msgid "Edit" +msgstr "Editar" + +#: data/ui/tour.list.ui:175 +msgid "Edit selected tour." +msgstr "Editar el tour seleccionado." + +#: data/ui/tour.list.ui:185 +msgid "New" +msgstr "Nuevo" + +#: data/ui/tour.list.ui:189 +msgid "Create a new tour." +msgstr "Crear un tour nuevo." + +#: data/ui/tour.list.ui:199 +msgid "Delete" +msgstr "Borrar" + +#: data/ui/tour.list.ui:203 +msgid "Delete selected tour." +msgstr "Borrar el tour seleccionado." + +#: data/ui/tour.list.ui:214 data/ui/query.window.ui:67 msgid "Close" msgstr "Cerrar" -#: data/ui/query.window.ui:85 -msgid "Run" -msgstr "Correr" - -#: data/ui/query.window.ui:127 -msgid "Statement" -msgstr "Enunciado" - -#: data/ui/query.window.ui:157 -msgid "View and Query" -msgstr "Vista y Consulta" - #: data/ui/tour.editor.ui:29 msgid "Tour Editor" msgstr "Editor de Tour" -#: data/ui/tour.editor.ui:54 data/ui/tour.list.ui:66 -msgid "Tour Name" -msgstr "Nombre del Tour" - -#: data/ui/tour.editor.ui:87 data/ui/tour.list.ui:80 -msgid "Individual Cost" -msgstr "Costo Individual" - -#: data/ui/tour.editor.ui:103 data/ui/tour.list.ui:94 -msgid "Group Cost" -msgstr "Costo Grupal" - -#: data/ui/tour.editor.ui:119 data/ui/tour.list.ui:108 -msgid "Minimum People" -msgstr "Mínima Personas" - -#: data/ui/tour.editor.ui:135 data/ui/tour.list.ui:136 -msgid "Region" -msgstr "Región" - -#: data/ui/tour.editor.ui:187 data/ui/tour.list.ui:122 -msgid "City" -msgstr "Ciudad" - #: data/ui/tour.editor.ui:234 msgid "Create a new region by typing here." msgstr "Crear una nueva región con escribir aquí." @@ -160,91 +214,88 @@ msgstr "Guardar" msgid "Save this tour." msgstr "Guardar este tour." -#: data/ui/tour.list.ui:168 -msgid "Edit" -msgstr "Editar" +#: data/ui/query.window.ui:85 +msgid "Run" +msgstr "Correr" -#: data/ui/tour.list.ui:173 -msgid "Edit selected tour." -msgstr "Editar el tour seleccionado." +#: data/ui/query.window.ui:127 +msgid "Statement" +msgstr "Enunciado" -#: data/ui/tour.list.ui:183 -msgid "New" -msgstr "Nuevo" +#: data/ui/query.window.ui:157 +msgid "View and Query" +msgstr "Vista y Consulta" -#: data/ui/tour.list.ui:187 -msgid "Create a new tour." -msgstr "Crear un tour nuevo." +#: data/ui/query.tree.ui:40 +msgid "Region Name" +msgstr "Nombre de Región" -#: data/ui/tour.list.ui:197 -msgid "Delete" -msgstr "Borrar" +#: data/ui/query.tree.ui:52 +msgid "Quantity" +msgstr "Cantidad" -#: data/ui/tour.list.ui:201 -msgid "Delete selected tour." -msgstr "Borrar el tour seleccionado." +#: data/ui/query.tree.ui:86 +msgid "Total Value" +msgstr "Valor Total" -#: src/main_window.vala:184 -msgid "Error" -msgstr "Error" +#: data/ui/query.tree.ui:114 +msgid "Coordinator Total" +msgstr "Total de Coordinadores" -#: src/sernatur.vala:88 -#, c-format -msgid "Error: %s\n" -msgstr "Error %s\n" +#: data/ui/query.tree.ui:142 +msgid "Tourist Total" +msgstr "Total de Turistas" -#: src/sernatur.vala:89 -#, c-format -msgid "Run '%s --help' to see a full list of available command line options.\n" -msgstr "" -"Correr '%s --help' para ver una lista completa de las opciones de la " -"consola.\n" +#: data/ui/query.tree.ui:164 +msgid "Percentage" +msgstr "Porcentaje" -#: src/sernatur.vala:94 -msgid "SERNATUR version: " -msgstr "Versión de SERNATUR: " +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:5 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:6 +msgid "Host to connect to" +msgstr "Servidor a conectar" -#~ msgid "Postgresql server version:" -#~ msgstr "Versión del servidor Postgresql:" +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:12 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:13 +msgid "Port number to use" +msgstr "Número de puerto a usar" -#~ msgid "The field %s was not found in the query results!" -#~ msgstr "La campo %s no estaba en los resultados de la consulta!" +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:19 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:20 +msgid "Options to use" +msgstr "Opciones a usar" -#~ msgid "The RUT %s has an invalid character!" -#~ msgstr "El RUT %s tiene un carácter invalido!" +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:26 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:27 +msgid "tty to send debug info (ignored)" +msgstr "tty para enviar datos de depuración (ignorado)" -#~ msgid "The RUT %s is too big!" -#~ msgstr "El RUT %s es demasiado grande!" +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:33 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:34 +msgid "Database to use" +msgstr "Base de dato a usar" -#~ msgid "The verifier %C is invalid!" -#~ msgstr "El verificador %C es invalido!" +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:40 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:41 +msgid "Username to use" +msgstr "Nombre de usuario a usar" -#~ msgid "Host to connect to" -#~ msgstr "Servidor a conectar" +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:47 +#: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:48 +msgid "Password to use" +msgstr "Contraseña a usar" -#~ msgid "Port number to use" -#~ msgstr "Número de puerto a usar" +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:5 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:6 +msgid "Should the program open maximized or not" +msgstr "Si el programa debe abrir maximizado ó no" -#~ msgid "Options to use" -#~ msgstr "Opciones a usar" +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:12 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:13 +msgid "Window width" +msgstr "El ancho de la ventana" -#~ msgid "tty to send debug info (ignored)" -#~ msgstr "tty para enviar datos de depuración (ignorado)" - -#~ msgid "Database to use" -#~ msgstr "Base de dato a usar" - -#~ msgid "Username to use" -#~ msgstr "Nombre de usuario a usar" - -#~ msgid "Password to use" -#~ msgstr "Contraseña a usar" - -#~ msgid "Should the program open maximized or not" -#~ msgstr "Si el programa debe abrir maximizado ó no" - -#~ msgid "Window width" -#~ msgstr "El ancho de la ventana" - -#~ msgid "Window height" -#~ msgstr "La altura de la venta" +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:19 +#: data/gschema/cl.cromer.ubb.sernatur.window.gschema.xml:20 +msgid "Window height" +msgstr "La altura de la venta" diff --git a/po/sernatur.pot b/po/sernatur.pot index 8f751c9..2910456 100644 --- a/po/sernatur.pot +++ b/po/sernatur.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: sernatur\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-01-13 19:10-0300\n" +"POT-Creation-Date: 2019-01-14 11:35-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -55,15 +55,39 @@ msgstr "" msgid "SERNATUR version: " msgstr "" -#: src/main_window.vala:184 +#: src/main_window.vala:216 +msgid "Error: Could not connect to the database!" +msgstr "" + +#: src/main_window.vala:228 msgid "Error" msgstr "" +#: src/query_window.vala:232 data/ui/main.window.ui:143 +msgid "(Q1) Regions with discounts" +msgstr "" + +#: src/query_window.vala:245 data/ui/main.window.ui:151 +msgid "(Q2) Tour values" +msgstr "" + +#: src/query_window.vala:258 data/ui/main.window.ui:159 +msgid "(Q3) Coordinator total" +msgstr "" + +#: src/query_window.vala:271 data/ui/main.window.ui:167 +msgid "(Q4) Tourist total" +msgstr "" + +#: src/query_window.vala:284 data/ui/main.window.ui:175 +msgid "(Q5) Vehicle total" +msgstr "" + #: data/ui/main.window.ui:44 msgid "_Menu" msgstr "" -#: data/ui/main.window.ui:54 data/ui/tour.list.ui:22 data/ui/query.window.ui:22 +#: data/ui/main.window.ui:54 data/ui/tour.list.ui:23 msgid "Tours" msgstr "" @@ -99,79 +123,60 @@ msgstr "" msgid "_Views" msgstr "" -#: data/ui/main.window.ui:143 -msgid "(Q1) Regions with discounts" -msgstr "" - -#: data/ui/main.window.ui:151 -msgid "(Q2) Tour values" -msgstr "" - -#: data/ui/main.window.ui:159 -msgid "(Q3) Coordinator total" -msgstr "" - -#: data/ui/main.window.ui:167 -msgid "(Q4) Tourist total" -msgstr "" - -#: data/ui/main.window.ui:175 -msgid "(Q5) Vehicle total" -msgstr "" - #: data/ui/main.splash.ui:46 msgid "Christopher Cromer" msgstr "" -#: data/ui/tour.list.ui:66 data/ui/tour.editor.ui:54 +#: data/ui/tour.list.ui:68 data/ui/tour.editor.ui:54 data/ui/query.tree.ui:80 +#: data/ui/query.tree.ui:108 data/ui/query.tree.ui:136 msgid "Tour Name" msgstr "" -#: data/ui/tour.list.ui:80 data/ui/tour.editor.ui:87 +#: data/ui/tour.list.ui:82 data/ui/tour.editor.ui:87 msgid "Individual Cost" msgstr "" -#: data/ui/tour.list.ui:94 data/ui/tour.editor.ui:103 +#: data/ui/tour.list.ui:96 data/ui/tour.editor.ui:103 msgid "Group Cost" msgstr "" -#: data/ui/tour.list.ui:108 data/ui/tour.editor.ui:119 +#: data/ui/tour.list.ui:110 data/ui/tour.editor.ui:119 msgid "Minimum People" msgstr "" -#: data/ui/tour.list.ui:122 data/ui/tour.editor.ui:187 +#: data/ui/tour.list.ui:124 data/ui/tour.editor.ui:187 msgid "City" msgstr "" -#: data/ui/tour.list.ui:136 data/ui/tour.editor.ui:135 +#: data/ui/tour.list.ui:138 data/ui/tour.editor.ui:135 msgid "Region" msgstr "" -#: data/ui/tour.list.ui:168 +#: data/ui/tour.list.ui:170 msgid "Edit" msgstr "" -#: data/ui/tour.list.ui:173 +#: data/ui/tour.list.ui:175 msgid "Edit selected tour." msgstr "" -#: data/ui/tour.list.ui:183 +#: data/ui/tour.list.ui:185 msgid "New" msgstr "" -#: data/ui/tour.list.ui:187 +#: data/ui/tour.list.ui:189 msgid "Create a new tour." msgstr "" -#: data/ui/tour.list.ui:197 +#: data/ui/tour.list.ui:199 msgid "Delete" msgstr "" -#: data/ui/tour.list.ui:201 +#: data/ui/tour.list.ui:203 msgid "Delete selected tour." msgstr "" -#: data/ui/tour.list.ui:212 data/ui/query.window.ui:67 +#: data/ui/tour.list.ui:214 data/ui/query.window.ui:67 msgid "Close" msgstr "" @@ -215,14 +220,30 @@ msgstr "" msgid "View and Query" msgstr "" -#: data/ui/query.1.ui:37 +#: data/ui/query.tree.ui:40 msgid "Region Name" msgstr "" -#: data/ui/query.1.ui:49 +#: data/ui/query.tree.ui:52 msgid "Quantity" msgstr "" +#: data/ui/query.tree.ui:86 +msgid "Total Value" +msgstr "" + +#: data/ui/query.tree.ui:114 +msgid "Coordinator Total" +msgstr "" + +#: data/ui/query.tree.ui:142 +msgid "Tourist Total" +msgstr "" + +#: data/ui/query.tree.ui:164 +msgid "Percentage" +msgstr "" + #: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:5 #: data/gschema/cl.cromer.ubb.sernatur.db.gschema.xml:6 msgid "Host to connect to" diff --git a/src/main_window.vala b/src/main_window.vala index 9a37b86..e00f1a7 100644 --- a/src/main_window.vala +++ b/src/main_window.vala @@ -39,10 +39,30 @@ namespace Sernatur { [GtkChild] private Gtk.MenuItem tours; /** - * The q1 menu item + * The Q1 menu item */ [GtkChild] private Gtk.MenuItem q1; + /** + * The Q2 menu item + */ + [GtkChild] + private Gtk.MenuItem q2; + /** + * The Q3 menu item + */ + [GtkChild] + private Gtk.MenuItem q3; + /** + * The Q4 menu item + */ + [GtkChild] + private Gtk.MenuItem q4; + /** + * The Q5 menu item + */ + [GtkChild] + private Gtk.MenuItem q5; /** * The quit menu item */ @@ -111,7 +131,31 @@ namespace Sernatur { tour_list.show_all (); } else if (menu_item == q1) { - var query_window = new QueryWindow (application, conn); + var query_window = new QueryWindow (application, conn, Query.Q1); + query_window.set_transient_for (this); // Set this window as the parent of the new window + query_window.initialize (); + query_window.show_all (); + } + else if (menu_item == q2) { + var query_window = new QueryWindow (application, conn, Query.Q2); + query_window.set_transient_for (this); // Set this window as the parent of the new window + query_window.initialize (); + query_window.show_all (); + } + else if (menu_item == q3) { + var query_window = new QueryWindow (application, conn, Query.Q3); + query_window.set_transient_for (this); // Set this window as the parent of the new window + query_window.initialize (); + query_window.show_all (); + } + else if (menu_item == q4) { + var query_window = new QueryWindow (application, conn, Query.Q4); + query_window.set_transient_for (this); // Set this window as the parent of the new window + query_window.initialize (); + query_window.show_all (); + } + else if (menu_item == q5) { + var query_window = new QueryWindow (application, conn, Query.Q5); query_window.set_transient_for (this); // Set this window as the parent of the new window query_window.initialize (); query_window.show_all (); @@ -169,7 +213,7 @@ namespace Sernatur { Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR, Gtk.ButtonsType.CLOSE, - e.message); + dgettext(null, "Error: Could not connect to the database!")); msg.response.connect ((response_id) => { switch (response_id) { case Gtk.ResponseType.CLOSE: diff --git a/src/queries.vala b/src/queries.vala index 03b98ae..aa1b2c8 100644 --- a/src/queries.vala +++ b/src/queries.vala @@ -17,13 +17,25 @@ namespace Sernatur { /** * The Q1 statement */ - public const string Q1_STATEMENT = "Genere la vista REGIONES SINDESCUENTO(nombreRegion, cantidad) que contiene el nombre -de cada región y la cantidad de personas a las que no se les ha aplicado descuento y que han -visitado algún lugar de la región en algún tour, durante el mes de noviembre del presente año. -Luego utilizando la vista, muestre las regiones que han recibido la mayor cantidad de turistas -sin descuento."; + public const string Q1_STATEMENT = "Genere la vista REGIONES_SINDESCUENTO(nombreRegion, cantidad) que contiene el nombre de cada región y la cantidad de personas a las que no se les ha aplicado descuento y que han visitado algún lugar de la región en algún tour, durante el mes de noviembre del presente año. Luego utilizando la vista, muestre las regiones que han recibido la mayor cantidad de turistas sin descuento."; /** - * The Q1 sql + * The Q2 statement + */ + public const string Q2_STATEMENT = "Genere la vista VALORES_TOURS(idT, nombreT, TotalVentas) que contiene el identificador y nombre de cada tour, además del total de ventas de cada tour. Par ello debe considerar todas las ventas realizadas del tour. Genere la vista TOUR_DESCUENTOS(idT, nombreT, TotalDescuentos) que contiene el identificador y nombre de cada tour, además del total de descuentos aplicados en todas las ventas de cada tour. Luego utilizando las vistas, muestre el nombre de los tours y valor total recibido, considerando el dinero recibido menos los descuentos."; + /** + * The Q3 statement + */ + public const string Q3_STATEMENT = "Genere la vista TOTAL_COORDINADORES(idT, nombreT, TotalCoordinadores) que almacena el identificador y nombre de los tour que poseen guı́as coordinadores con más de tres especialidades y que han participado en tours que visitan lugares con nivel de esfuerzo medio. Luego, utilizando la vista, muestre los tours que poseen la mayor cantidad de coordinadores con las caracterı́sticas mencionadas."; + /** + * The Q4 statement + */ + public const string Q4_STATEMENT = "Genere la vista TOTAL_TURISTAS(idT, nombreT, TotalTuristas) que contiene el identificador y nombre de los tours, y la cantidad de turistas que no tienen enfermedades cardı́acas ni respiratorias y que han visitado lugares cuyo nivel de exigencia es experto durante el mes de octubre del presente año. Luego, utilizando la vista, muestre los tours que poseen la mayor cantidad de turistas que han visitado lugares con exigencia experto y que cumplan el requisito de no tener las enfermedades mencionadas."; + /** + * The Q5 statement + */ + public const string Q5_STATEMENT = "Genere la vista TOTAL_ARRIENDOS(TotalArriendo) que almacena el total de arriendos de vehı́culos (no precio) realizados por SERNATUR durante los meses de Enero y Febrero del presente año y la vista TOTAL_VEHICULOS(TotalVeh) que contiene el total de vehı́culos que posee SERNATUR. Luego, utilizando las vistas muestre el porcentaje de arriendo de vehı́culos realizados por SERNATUR (número de vehı́culos arrendados/número total de vehı́culos)."; + /** + * The Q1 SQL */ public const string Q1_SQL = "CREATE VIEW REGIONES_SINDESCUENTO(nombreRegion, cantidad) AS ( @@ -40,5 +52,21 @@ AS ( GROUP BY (R.nombre_region) ); SELECT nombreRegion, cantidad FROM REGIONES_SINDESCUENTO WHERE (cantidad = (SELECT MAX(cantidad) FROM REGIONES_SINDESCUENTO));"; + /** + * The Q2 SQL + */ + public const string Q2_SQL = ""; + /** + * The Q3 SQL + */ + public const string Q3_SQL = ""; + /** + * The Q4 SQL + */ + public const string Q4_SQL = ""; + /** + * The Q5 SQL + */ + public const string Q5_SQL = ""; } } diff --git a/src/query_window.vala b/src/query_window.vala index 3af2aae..3588c63 100644 --- a/src/query_window.vala +++ b/src/query_window.vala @@ -27,15 +27,29 @@ namespace Sernatur { */ private Connection conn; /** - * The columns of the tree view + * The queries that can be called */ - private enum Column { + public enum Query { + Q1, + Q2, + Q3, + Q4, + Q5 + } + /** + * The query to use in the object + */ + private Query query; + /** + * The columns of the Q1 tree view + */ + private enum Q1Column { /** - * The tour name + * The region name */ REGION_NAME, /** - * The individual cost + * The quantity */ QUANTITY, /** @@ -43,6 +57,70 @@ namespace Sernatur { */ N_COLUMNS } + /** + * The columns of the Q2 tree view + */ + private enum Q2Column { + /** + * The tour name + */ + TOUR_NAME, + /** + * The total value + */ + TOTAL_VALUE, + /** + * The number of colums in this enum + */ + N_COLUMNS + } + /** + * The columns of the Q3 tree view + */ + private enum Q3Column { + /** + * The tour name + */ + TOUR_NAME, + /** + * The total of coordinators + */ + COORDINATOR_TOTAL, + /** + * The number of colums in this enum + */ + N_COLUMNS + } + /** + * The columns of the Q4 tree view + */ + private enum Q4Column { + /** + * The tour name + */ + TOUR_NAME, + /** + * The total of turists + */ + TOURIST_TOTAL, + /** + * The number of colums in this enum + */ + N_COLUMNS + } + /** + * The columns of the Q5 tree view + */ + private enum Q5Column { + /** + * The percentage + */ + PERCENTAGE, + /** + * The number of colums in this enum + */ + N_COLUMNS + } /** * The list that stores the contents in the tree view */ @@ -52,14 +130,29 @@ namespace Sernatur { */ [GtkChild] private Gtk.ScrolledWindow scroll_window; + /** + * The statement label + */ [GtkChild] private Gtk.Label statement; + /** + * The sql label + */ [GtkChild] private Gtk.Label sql; + /** + * The run button + */ [GtkChild] private Gtk.Button run_query; + /** + * The close button + */ [GtkChild] private Gtk.Button close_query; + /** + * The query tree + */ private Gtk.TreeView query_tree; /** @@ -70,15 +163,17 @@ namespace Sernatur { public void on_clicked_button (Gtk.Button button) { if (button == run_query) { list_store.clear (); - var region_list = RegionesSinDescuento.get_regions (conn.db); + if (query == Query.Q1) { + var region_list = RegionesSinDescuento.get_regions (conn.db); - region_list.foreach ((entry) => { - Gtk.TreeIter iter; - list_store.append (out iter); - list_store.set (iter, - Column.REGION_NAME, entry.nombre_region, - Column.QUANTITY, entry.cantidad); - }); + region_list.foreach ((entry) => { + Gtk.TreeIter iter; + list_store.append (out iter); + list_store.set (iter, + Q1Column.REGION_NAME, entry.nombre_region, + Q1Column.QUANTITY, entry.cantidad); + }); + } } else if (button == close_query) { this.close (); @@ -89,17 +184,33 @@ namespace Sernatur { * Initialize the tour list class * @param application The application used to make the GLib object * @param conn The database connection to use + * @param query The query to show */ - public QueryWindow (Gtk.Application application, Connection conn) { + public QueryWindow (Gtk.Application application, Connection conn, Query query) { GLib.Object (application: application); this.conn = conn; + this.query = query; // Load scroll window's content var builder = new Gtk.Builder (); try { - builder.add_from_resource ("/cl/cromer/ubb/sernatur/query.1.ui"); + builder.add_from_resource ("/cl/cromer/ubb/sernatur/query.tree.ui"); builder.connect_signals (null); - query_tree = builder.get_object ("query_tree") as Gtk.TreeView; + if (query == Query.Q1) { + query_tree = builder.get_object ("query_tree_q1") as Gtk.TreeView; + } + else if (query == Query.Q2) { + query_tree = builder.get_object ("query_tree_q2") as Gtk.TreeView; + } + else if (query == Query.Q3) { + query_tree = builder.get_object ("query_tree_q3") as Gtk.TreeView; + } + else if (query == Query.Q4) { + query_tree = builder.get_object ("query_tree_q4") as Gtk.TreeView; + } + else if (query == Query.Q5) { + query_tree = builder.get_object ("query_tree_q5") as Gtk.TreeView; + } query_tree.set_visible (true); // Add logo to scroll window @@ -117,17 +228,70 @@ namespace Sernatur { * Initialize what is needed for this window */ public void initialize () { - this.set_title ("Test"); + if (query == Query.Q1) { + this.set_title (dgettext (null, "(Q1) Regions with discounts")); - list_store = new Gtk.ListStore (Column.N_COLUMNS, - typeof (string), - typeof (uint)); + list_store = new Gtk.ListStore (Q1Column.N_COLUMNS, + typeof (string), + typeof (uint)); - query_tree.set_model (list_store); + query_tree.set_model (list_store); - statement.set_text (Q1_STATEMENT); + statement.set_text (Q1_STATEMENT); - sql.set_text (Q1_SQL); + sql.set_text (Q1_SQL); + } + else if (query == Query.Q2) { + this.set_title (dgettext (null, "(Q2) Tour values")); + + list_store = new Gtk.ListStore (Q2Column.N_COLUMNS, + typeof (string), + typeof (uint)); + + query_tree.set_model (list_store); + + statement.set_text (Q2_STATEMENT); + + sql.set_text (Q2_SQL); + } + else if (query == Query.Q3) { + this.set_title (dgettext (null, "(Q3) Coordinator total")); + + list_store = new Gtk.ListStore (Q3Column.N_COLUMNS, + typeof (string), + typeof (uint)); + + query_tree.set_model (list_store); + + statement.set_text (Q3_STATEMENT); + + sql.set_text (Q3_SQL); + } + else if (query == Query.Q4) { + this.set_title (dgettext (null, "(Q4) Tourist total")); + + list_store = new Gtk.ListStore (Q4Column.N_COLUMNS, + typeof (string), + typeof (uint)); + + query_tree.set_model (list_store); + + statement.set_text (Q4_STATEMENT); + + sql.set_text (Q4_SQL); + } + else if (query == Query.Q5) { + this.set_title (dgettext (null, "(Q5) Vehicle total")); + + list_store = new Gtk.ListStore (Q5Column.N_COLUMNS, + typeof (float)); + + query_tree.set_model (list_store); + + statement.set_text (Q5_STATEMENT); + + sql.set_text (Q5_SQL); + } } } }