[chronojump] Tags are shown on load session
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Tags are shown on load session
- Date: Tue, 24 Nov 2020 12:30:17 +0000 (UTC)
commit 0c3464a4a3f7a6e88e0182a5e3e2c76480255f5c
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Nov 24 13:29:57 2020 +0100
Tags are shown on load session
src/gui/app1/session/loadAndImport.cs | 56 +++++++++++++++++++++++---------
src/gui/app1/session/tagSessionSelect.cs | 2 +-
src/sqlite/tagSession.cs | 38 +++++++++++++++++++++-
src/tagSession.cs | 48 ++++++++++++++++++++++++++-
4 files changed, 126 insertions(+), 18 deletions(-)
---
diff --git a/src/gui/app1/session/loadAndImport.cs b/src/gui/app1/session/loadAndImport.cs
index 080b0393..ef7bab2c 100644
--- a/src/gui/app1/session/loadAndImport.cs
+++ b/src/gui/app1/session/loadAndImport.cs
@@ -23,6 +23,7 @@ using Gtk;
using Glade;
using GLib; //for Value
using System.Text; //StringBuilder
+using System.Collections.Generic; //List<T>
using System.Collections; //ArrayList
using Mono.Unix;
@@ -106,8 +107,8 @@ public partial class ChronoJumpWindow
}
app1s_entry_search_filter.Text = "";
- app1s_createTreeView(app1s_treeview_session_load, false, false, false);
- app1s_store = app1s_getStore(false, false, false);
+ app1s_createTreeView(app1s_treeview_session_load, true, false, false, false);
+ app1s_store = app1s_getStore(true, false, false, false);
app1s_treeview_session_load.Model = app1s_store;
app1s_fillTreeView(app1s_treeview_session_load, app1s_store, false, false, false);
@@ -131,9 +132,12 @@ public partial class ChronoJumpWindow
*/
}
- private TreeStore app1s_getStore(bool showPersons, bool showContacts, bool showOtherTests)
+ private TreeStore app1s_getStore(bool loadOrImport, bool showPersons, bool showContacts, bool
showOtherTests)
{
int columns = 6;
+ if(loadOrImport)
+ columns ++; //on load we have the tags column
+
if(showPersons)
columns += 3;
if(showContacts)
@@ -179,7 +183,7 @@ public partial class ChronoJumpWindow
app1s_recreateTreeView("loaded the dialog");
}
- private void app1s_createTreeView (Gtk.TreeView tv, bool showPersons, bool showContacts, bool
showOtherTests)
+ private void app1s_createTreeView (Gtk.TreeView tv, bool loadOrImport, bool showPersons, bool
showContacts, bool showOtherTests)
{
tv.HeadersVisible=true;
int count = 0;
@@ -200,7 +204,10 @@ public partial class ChronoJumpWindow
colName.SortColumnId = count ++;
colName.SortIndicator = true;
tv.AppendColumn (colName);
-
+
+ if(loadOrImport)
+ tv.AppendColumn ( Catalog.GetString ("Tags"), new CellRendererText(), "text",
count++);
+
tv.AppendColumn ( Catalog.GetString ("Place"), new CellRendererText(), "text", count++);
tv.AppendColumn ( Catalog.GetString ("Persons"), new CellRendererText(), "text", count++);
if(showPersons) {
@@ -273,11 +280,12 @@ public partial class ChronoJumpWindow
UtilGtk.RemoveColumns(app1s_treeview_session_load);
- app1s_createTreeView(app1s_treeview_session_load,
+ app1s_createTreeView(app1s_treeview_session_load, true,
app1s_checkbutton_show_data_persons.Active,
app1s_checkbutton_show_data_jump_run.Active,
app1s_checkbutton_show_data_other_tests.Active);
app1s_store = app1s_getStore(
+ true,
app1s_checkbutton_show_data_persons.Active,
app1s_checkbutton_show_data_jump_run.Active,
app1s_checkbutton_show_data_other_tests.Active);
@@ -315,6 +323,24 @@ public partial class ChronoJumpWindow
SqliteSessionSwitcher sessionSwitcher = new SqliteSessionSwitcher (databaseType,
app1s_import_file_path);
string [] mySessions = sessionSwitcher.SelectAllSessions(filterName); //returns a string of
values separated by ':'
+
+ //new 2.0 code
+ int columns = 6;
+ if(showPersons)
+ columns += 3;
+ if(showContacts)
+ columns += 7;
+ if(showOtherTests)
+ columns += 4;
+
+ //tags are not going to be imported right now, so use only on load session
+ List<SessionTagSession> tagsOfAllSessions = new List<SessionTagSession>();
+ if (app1s_type == app1s_windowType.LOAD_SESSION)
+ {
+ tagsOfAllSessions = SqliteSessionTagSession.SelectTagsOfAllSessions(false);
+ columns ++;
+ }
+
foreach (string session in mySessions)
{
string [] myStringFull = session.Split(new char[] {':'});
@@ -332,15 +358,6 @@ public partial class ChronoJumpWindow
if (myStringFull[6] != Catalog.GetString(Constants.LevelUndefined))
myLevel = Catalog.GetString(myStringFull[6]);
- //new 2.0 code
- int columns = 6;
- if(showPersons)
- columns += 3;
- if(showContacts)
- columns += 7;
- if(showOtherTests)
- columns += 4;
-
string [] strings = new string [columns];
//for (int i=0; i < columns; i++) {
// types[i] = typeof (string);
@@ -349,6 +366,15 @@ public partial class ChronoJumpWindow
strings[i ++] = myStringFull[0]; //session num
strings[i ++] = myStringFull[3]; //session date
strings[i ++] = myStringFull[1]; //session name
+
+ if (app1s_type == app1s_windowType.LOAD_SESSION)
+ {
+ List<TagSession> tagSession_list = SessionTagSession.FindTagSessionsOfSession(
+ Convert.ToInt32(myStringFull[0]),
+ tagsOfAllSessions);
+ strings[i ++] = SessionTagSession.PrintTagNamesOfSession(tagSession_list);
+ }
+
strings[i ++] = myStringFull[2]; //session place
strings[i ++] = myStringFull[8]; //number of jumpers x session
diff --git a/src/gui/app1/session/tagSessionSelect.cs b/src/gui/app1/session/tagSessionSelect.cs
index 51e67122..964bffb5 100644
--- a/src/gui/app1/session/tagSessionSelect.cs
+++ b/src/gui/app1/session/tagSessionSelect.cs
@@ -78,7 +78,7 @@ public class TagSessionSelect
private void getData()
{
allTags_list = SqliteTagSession.Select(false, -1);
- tagsActiveThisSession_list = SqliteSessionTagSession.Select(false, currentSessionID);
+ tagsActiveThisSession_list = SqliteSessionTagSession.SelectTagsOfASession(false,
currentSessionID);
}
private void createBigArray()
diff --git a/src/sqlite/tagSession.cs b/src/sqlite/tagSession.cs
index 39efbaa4..48d92fd0 100644
--- a/src/sqlite/tagSession.cs
+++ b/src/sqlite/tagSession.cs
@@ -173,7 +173,7 @@ class SqliteSessionTagSession : Sqlite
}
//gets the active tagSessions in session
- public static List<TagSession> Select (bool dbconOpened, int sessionID)
+ public static List<TagSession> SelectTagsOfASession (bool dbconOpened, int sessionID)
{
openIfNeeded(dbconOpened);
@@ -205,6 +205,42 @@ class SqliteSessionTagSession : Sqlite
return list;
}
+ public static List<SessionTagSession> SelectTagsOfAllSessions (bool dbconOpened)
+ {
+ openIfNeeded(dbconOpened);
+
+ dbcmd.CommandText = "SELECT sessionTagSession.sessionID, tagSession.* FROM tagSession,
sessionTagSession " +
+ "WHERE tagSession.uniqueID = sessionTagSession.tagSessionID ORDER BY NAME";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ List<SessionTagSession> list = new List<SessionTagSession>();
+
+ while(reader.Read())
+ {
+ SessionTagSession sts = new SessionTagSession
+ (
+ Convert.ToInt32(reader[0].ToString()), //sessionID
+ new TagSession (
+ Convert.ToInt32(reader[1].ToString()), //uniqueID
+ reader[2].ToString(), //name
+ reader[3].ToString(), //color
+ reader[4].ToString() //comments
+ )
+ );
+ list.Add(sts);
+ }
+
+ reader.Close();
+ closeIfNeeded(dbconOpened);
+
+ return list;
+ }
+
public static void UpdateTransaction(int sessionID, ArrayList allTags_list,
List<TagSession> tagsActiveThisSession_list, string [] checkboxes)
{
diff --git a/src/tagSession.cs b/src/tagSession.cs
index e471505a..3b564872 100644
--- a/src/tagSession.cs
+++ b/src/tagSession.cs
@@ -78,7 +78,7 @@ public class TagSession
public static string GetActiveTagNamesOfThisSession(int sessionID)
{
string str = "";
- List<TagSession> tagSession_l = SqliteSessionTagSession.Select(false, sessionID);
+ List<TagSession> tagSession_l = SqliteSessionTagSession.SelectTagsOfASession(false,
sessionID);
string sep = "";
foreach(TagSession tagSession in tagSession_l)
@@ -99,3 +99,49 @@ public class TagSession
}
}
+//manages the tagSession and its session
+public class SessionTagSession
+{
+ private int sessionID;
+ private TagSession ts;
+
+ public SessionTagSession (int sessionID, TagSession ts)
+ {
+ this.sessionID = sessionID;
+ this.ts = ts;
+ }
+
+ //methods for managing list of TagSesssion or SessionTagSession
+
+ public static List<TagSession> FindTagSessionsOfSession (int sessionID, List<SessionTagSession>
tagsAndSessions_list)
+ {
+ List<TagSession> tags_list = new List<TagSession>();
+ foreach(SessionTagSession sts in tagsAndSessions_list)
+ if(sts.SessionID == sessionID)
+ tags_list.Add(sts.Ts);
+
+ return tags_list;
+ }
+
+ public static string PrintTagNamesOfSession (List<TagSession> tags_list)
+ {
+ string str = "";
+ string sep = "";
+ foreach(TagSession ts in tags_list)
+ {
+ str += sep + ts.Name;
+ sep = ", ";
+ }
+
+ return str;
+ }
+
+ public int SessionID
+ {
+ get { return sessionID; }
+ }
+ public TagSession Ts
+ {
+ get { return ts; }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]