[chronojump] DB:2.04 Created tables: tagSession, sessionTagSession, and started classes and gui
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] DB:2.04 Created tables: tagSession, sessionTagSession, and started classes and gui
- Date: Fri, 20 Nov 2020 13:16:38 +0000 (UTC)
commit 8ea065a905293bef1e887bb2279b637b3e24d8a9
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Nov 20 14:15:57 2020 +0100
DB:2.04 Created tables: tagSession, sessionTagSession, and started classes and gui
glade/app1.glade | 95 ++++++++++++++++++----
src/Makefile.am | 3 +
src/constants.cs | 2 +
src/gui/app1/session/addEdit.cs | 7 +-
src/gui/app1/session/tagSessionSelect.cs | 97 ++++++++++++++++++++++
src/sqlite/main.cs | 16 +++-
src/sqlite/tagSession.cs | 133 +++++++++++++++++++++++++++++++
src/tagSession.cs | 77 ++++++++++++++++++
8 files changed, 410 insertions(+), 20 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 3491293b..df300534 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -23278,6 +23278,9 @@ Concentric</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -28021,18 +28024,6 @@ Concentric</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
- <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Tests
will be filmed</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
<widget class="GtkHBox"
id="hbox_video_encoder_capturing">
<property name="can_focus">False</property>
<property name="spacing">4</property>
@@ -28069,6 +28060,18 @@ Concentric</property>
</packing>
</child>
<child>
+ <widget class="GtkLabel"
id="label_video_encoder_tests_will_be_filmed">
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Tests
will be filmed</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkHBox"
id="hbox_video_encoder_no_capturing">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -36196,6 +36199,9 @@ then click this button.</property>
<child>
<placeholder/>
</child>
+ <child>
+ <placeholder/>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -39529,7 +39535,7 @@ then click this button.</property>
<child>
<widget class="GtkFrame" id="frame18">
<property name="width_request">550</property>
- <property name="height_request">425</property>
+ <property name="height_request">475</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
@@ -39562,7 +39568,7 @@ then click this button.</property>
<widget class="GtkTable" id="table13">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">3</property>
+ <property name="n_rows">4</property>
<property name="n_columns">2</property>
<property name="column_spacing">8</property>
<property name="row_spacing">12</property>
@@ -39642,8 +39648,8 @@ then click this button.</property>
<property name="use_markup">True</property>
</widget>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"/>
</packing>
@@ -39667,7 +39673,7 @@ then click this button.</property>
</child>
<child>
<widget class="GtkButton"
id="app1sae_button_change_date">
- <property name="label"
translatable="yes">change</property>
+ <property name="label"
translatable="yes">Change</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property
name="receives_default">False</property>
@@ -39686,6 +39692,61 @@ then click this button.</property>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label260">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label"
translatable="yes">Tags</property>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox338">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">4</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel"
id="app1sae_label_tags_selected">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton"
id="app1sae_button_select_tags">
+ <property name="label"
translatable="yes">Select</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">False</property>
+ <property name="relief">half</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked"
handler="on_app1sae_button_select_tags_clicked" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">end</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options">GTK_FILL</property>
diff --git a/src/Makefile.am b/src/Makefile.am
index f3cfbe12..d0e86e8e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,6 +24,7 @@ SOURCES = \
gui/app1/session/export.cs\
gui/app1/session/loadAndImport.cs\
gui/app1/session/main.cs\
+ gui/app1/session/tagSessionSelect.cs\
gui/app1/jump.cs\
gui/app1/menu.cs\
gui/app1/menu_tiny.cs\
@@ -162,6 +163,7 @@ SOURCES = \
sqlite/json.cs\
sqlite/sport.cs\
sqlite/speciallity.cs\
+ sqlite/tagSession.cs\
sqlite/trigger.cs\
sqlite/usefulObjects.cs\
sqlite/country.cs\
@@ -224,6 +226,7 @@ SOURCES = \
preferences.cs\
restTime.cs\
sprint.cs\
+ tagSession.cs\
threshold.cs\
treeview/event.cs\
treeview/person.cs\
diff --git a/src/constants.cs b/src/constants.cs
index 8c64bd8a..7fac1485 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -145,6 +145,8 @@ public class Constants
public const string PersonSessionOldWeightTable = "personSessionWeight"; //old table, used from db
0.53 to 0.76
public const string SessionTable = "session";
+ public const string TagSessionTable = "tagSession";
+ public const string SessionTagSessionTable = "sessionTagSession";
public const string PersonNotUploadTable = "personSessionNotUpload";
public const string SportTable = "sport";
public const string SpeciallityTable = "speciallity";
diff --git a/src/gui/app1/session/addEdit.cs b/src/gui/app1/session/addEdit.cs
index 26e00117..b16e0690 100644
--- a/src/gui/app1/session/addEdit.cs
+++ b/src/gui/app1/session/addEdit.cs
@@ -532,7 +532,12 @@ public partial class ChronoJumpWindow
else
app1s_notebook.CurrentPage = app1s_PAGE_MODES;
}
-
+
+ private void on_app1sae_button_select_tags_clicked (object o, EventArgs args)
+ {
+ new TagSessionSelect();
+ }
+
void app1sae_on_button_change_date_clicked (object o, EventArgs args)
{
app1sae_dialogCalendar = new DialogCalendar(Catalog.GetString("Select session date"),
app1sae_dateTime);
diff --git a/src/gui/app1/session/tagSessionSelect.cs b/src/gui/app1/session/tagSessionSelect.cs
new file mode 100644
index 00000000..42d181a2
--- /dev/null
+++ b/src/gui/app1/session/tagSessionSelect.cs
@@ -0,0 +1,97 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2020 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.IO;
+using Gtk;
+using Gdk;
+using Glade;
+using System.Collections;
+using System.Collections.Generic; //List<T>
+using Mono.Unix;
+
+//adapted from src/gui/encoderSelectRepetitions.cs
+public class TagSessionSelect
+{
+ private ArrayList data;
+ private ArrayList dataPrint;
+ private static GenericWindow genericWin;
+ private string [] columnsString;
+ private ArrayList bigArray;
+ private string [] checkboxes;
+
+ //passed variables
+
+ public void Do() {
+ getData();
+ createBigArray();
+ nullifyGenericWindow();
+ createGenericWindow();
+ }
+
+ private void getData()
+ {
+ data = SqliteTagSession.Select(false, -1);
+ }
+
+ private void createBigArray()
+ {
+ dataPrint = new ArrayList();
+ checkboxes = new string[data.Count]; //to store active or inactive status of tags
+ int count = 0;
+ foreach(TagSession tagS in data) {
+ checkboxes[count++] = "inactive";
+ dataPrint.Add(tagS.ToStringArray());
+ }
+
+ columnsString = new string[] {
+ "ID",
+ Catalog.GetString("Name"),
+ Catalog.GetString("Color"),
+ Catalog.GetString("Comments")
+ };
+
+ bigArray = new ArrayList();
+ ArrayList a1 = new ArrayList();
+
+ //0 is the widgget to show; 1 is the editable; 2 id default value
+ a1.Add(Constants.GenericWindowShow.TREEVIEW); a1.Add(true); a1.Add("");
+ bigArray.Add(a1);
+ }
+
+ private void nullifyGenericWindow()
+ {
+ if(genericWin != null && ! genericWin.GenericWindowBoxIsNull())
+ genericWin.HideAndNull();
+ }
+
+ private void createGenericWindow()
+ {
+ genericWin = GenericWindow.Show(Catalog.GetString("Tags"), false, //don't show now
+ "", bigArray);
+
+ genericWin.SetTreeview(columnsString, true, dataPrint, new ArrayList(),
GenericWindow.EditActions.NONE, false);
+
+ //TODO: continue...
+ }
+
+
+
+}
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index d44a11de..902bee41 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -129,7 +129,7 @@ class Sqlite
/*
* Important, change this if there's any update to database
*/
- static string lastChronojumpDatabaseVersion = "2.03";
+ static string lastChronojumpDatabaseVersion = "2.04";
public Sqlite()
{
@@ -2801,6 +2801,15 @@ class Sqlite
currentVersion = updateVersion("2.03");
}
+ if(currentVersion == "2.03")
+ {
+ LogB.SQL("Created tables: tagSession, sessionTagSession");
+
+ SqliteTagSession.createTable();
+ SqliteSessionTagSession.createTable();
+
+ currentVersion = updateVersion("2.04");
+ }
/*
if(currentVersion == "1.79")
@@ -2898,7 +2907,9 @@ class Sqlite
SqlitePersonSessionNotUpload.CreateTable();
creationRate ++;
}
-
+
+ SqliteTagSession.createTable();
+ SqliteSessionTagSession.createTable();
SqlitePerson sqlitePersonObject = new SqlitePerson();
sqlitePersonObject.createTable(Constants.PersonTable);
@@ -3016,6 +3027,7 @@ class Sqlite
//just testing: 1.79 - 1.80 Converted DB to 1.80 Created table ForceSensorElasticBandGlue and moved
stiffnessString records there
+ //2.03 - 2.04 Converted DB to 2.04 Created tables: tagSession, sessionTagSession
//2.02 - 2.03 Converted DB to 2.03 Inserted into preferences: encoderInertialGraphsX
//2.01 - 2.02 Converted DB to 2.02 Inserted into preferences: restTimeMinutes,
restTimeSeconds")
//2.00 - 2.01 Converted DB to 2.01 RunEncoderExercise ALTER TABLE: added column segmentMeters
diff --git a/src/sqlite/tagSession.cs b/src/sqlite/tagSession.cs
new file mode 100644
index 00000000..ce5ba73c
--- /dev/null
+++ b/src/sqlite/tagSession.cs
@@ -0,0 +1,133 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2020 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+//using System.Data;
+using System.Collections;
+using System.Collections.Generic; //List<T>
+using Mono.Data.Sqlite;
+
+class SqliteTagSession : Sqlite
+{
+ private static string table = Constants.TagSessionTable;
+
+ public SqliteTagSession() {
+ }
+
+ ~SqliteTagSession() {}
+
+ /*
+ * create and initialize tables
+ */
+
+
+ protected internal static void createTable ()
+ {
+ dbcmd.CommandText =
+ "CREATE TABLE " + table + " ( " +
+ "uniqueID INTEGER PRIMARY KEY, " +
+ "name TEXT, " +
+ "color TEXT, " +
+ "comments TEXT )";
+ dbcmd.ExecuteNonQuery();
+ }
+
+ public static int Insert (bool dbconOpened, string insertString)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "INSERT INTO " + table +
+ " (uniqueID, name, color, comments)" +
+ " VALUES " + insertString;
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ string myString = @"select last_insert_rowid()";
+ dbcmd.CommandText = myString;
+ int myLast = Convert.ToInt32(dbcmd.ExecuteScalar()); // Need to type-cast since
`ExecuteScalar` returns an object.
+
+ closeIfNeeded(dbconOpened);
+
+ return myLast;
+ }
+
+ public static ArrayList Select (bool dbconOpened, int uniqueID)
+ {
+ openIfNeeded(dbconOpened);
+
+ string selectStr = "SELECT * FROM " + table;
+
+ string uniqueIDStr = "";
+ if(uniqueID != -1)
+ uniqueIDStr = " WHERE " + table + ".uniqueID = " + uniqueID;
+
+ dbcmd.CommandText = selectStr + uniqueIDStr + " Order BY " + table + ".uniqueID";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ ArrayList array = new ArrayList(1);
+ TagSession tagS;
+
+ while(reader.Read()) {
+ tagS = new TagSession (
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ reader[1].ToString(), //name
+ reader[2].ToString(), //color
+ reader[3].ToString() //comments
+ );
+ array.Add(tagS);
+ }
+
+ reader.Close();
+ closeIfNeeded(dbconOpened);
+
+ return array;
+ }
+
+}
+
+class SqliteSessionTagSession : Sqlite
+{
+ private static string table = Constants.SessionTagSessionTable;
+
+ public SqliteSessionTagSession() {
+ }
+
+ ~SqliteSessionTagSession() {}
+
+ /*
+ * create and initialize tables
+ */
+
+
+ protected internal static void createTable ()
+ {
+ dbcmd.CommandText =
+ "CREATE TABLE " + table + " ( " +
+ "uniqueID INTEGER PRIMARY KEY, " +
+ "sessionID INT, " +
+ "tagSessionID INT )";
+ dbcmd.ExecuteNonQuery();
+ }
+}
diff --git a/src/tagSession.cs b/src/tagSession.cs
new file mode 100644
index 00000000..faf431db
--- /dev/null
+++ b/src/tagSession.cs
@@ -0,0 +1,77 @@
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * ChronoJump is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Copyright (C) 2020 Xavier de Blas <xaviblas gmail com>
+ */
+
+using System;
+using System.IO; //for detect OS //TextWriter
+using System.Collections.Generic; //List<T>
+using Mono.Unix;
+
+public class TagSession
+{
+ private int uniqueID;
+ private string name;
+ private string color;
+ private string comments;
+
+ /* constructors */
+
+ //have a uniqueID -1 contructor, useful when set is deleted
+ public TagSession()
+ {
+ uniqueID = -1;
+ }
+
+ //constructor
+ public TagSession(int uniqueID, string name, string color, string comments)
+ {
+ this.uniqueID = uniqueID;
+ this.name = name;
+ this.color = color;
+ this.comments = comments;
+ }
+
+ /* methods */
+
+ public int InsertSQL(bool dbconOpened)
+ {
+ return SqliteTagSession.Insert(dbconOpened, toSQLInsertString());
+ }
+ private string toSQLInsertString()
+ {
+ string uniqueIDStr = "NULL";
+ if(uniqueID != -1)
+ uniqueIDStr = uniqueID.ToString();
+
+ return
+ uniqueIDStr + ", \"" + name + "\", \"" + color + "\", \"" + comments + "\"";
+ }
+
+ public string [] ToStringArray ()
+ {
+ string [] str = new String [4];
+ str[0] = uniqueID.ToString();
+ str[1] = name;
+ str[2] = color;
+ str[3] = comments;
+
+ return str;
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]