[chronojump] RunEncoder session overview: done!



commit 2972aadc96cba41e70abcf3f7b956ad902cb50de
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Oct 8 13:36:38 2019 +0200

    RunEncoder session overview: done!

 glade/app1.glade         |  9 +++++
 src/gui/chronojump.cs    |  2 ++
 src/gui/overview.cs      | 86 +++++++++++++++++++++++++++++++++++++-----------
 src/gui/runEncoder.cs    |  5 +++
 src/sqlite/runEncoder.cs | 35 ++++++++++++++++++++
 5 files changed, 118 insertions(+), 19 deletions(-)
---
diff --git a/glade/app1.glade b/glade/app1.glade
index 4b6232d0..06d198fa 100644
--- a/glade/app1.glade
+++ b/glade/app1.glade
@@ -575,6 +575,15 @@
                         </child>
                       </widget>
                     </child>
+                    <child>
+                      <widget class="GtkMenuItem" id="menuitem_runEncoder_session_overview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Overview of this session</property>
+                        <property name="use_underline">True</property>
+                        <signal name="activate" handler="on_menuitem_runEncoder_session_overview_activate" 
swapped="no"/>
+                      </widget>
+                    </child>
                     <child>
                       <widget class="GtkCheckMenuItem" id="menuitem_check_race_encoder_capture_simulate">
                         <property name="can_focus">False</property>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 71bb48be..3428ed4a 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -200,6 +200,7 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.MenuItem menuitem_export_csv;
        [Widget] Gtk.MenuItem menuitem_encoder_session_overview;
        [Widget] Gtk.MenuItem menuitem_forceSensor_session_overview;
+       [Widget] Gtk.MenuItem menuitem_runEncoder_session_overview;
        [Widget] Gtk.Image image_session_open;
 
        //menu person
@@ -7226,6 +7227,7 @@ LogB.Debug("mc finished 5");
                //menuitem_export_xml.Sensitive = option; not implemented yet
                menuitem_encoder_session_overview.Sensitive = option;
                menuitem_forceSensor_session_overview.Sensitive = option;
+               menuitem_runEncoder_session_overview.Sensitive = option;
        }
        
        private void menuPersonSelectedSensitive(bool option)
diff --git a/src/gui/overview.cs b/src/gui/overview.cs
index 452a38b5..7486a54a 100644
--- a/src/gui/overview.cs
+++ b/src/gui/overview.cs
@@ -65,10 +65,21 @@ public abstract class OverviewWindow
                        store.AppendValues (line);
        }
 
+       protected virtual void createTreeView(Gtk.TreeView tv, treeviewType type)
+       {
+               tv.HeadersVisible=true;
+               int count = 0;
 
-       protected abstract void createTreeView(Gtk.TreeView tv, treeviewType type);
+               tv.AppendColumn (Catalog.GetString ("Person"), new CellRendererText(), "text", count++);
+               tv.AppendColumn (Catalog.GetString ("Sex"), new CellRendererText(), "text", count++);
+               tv.AppendColumn (Catalog.GetString ("Exercise"), new CellRendererText(), "text", count++);
+               tv.AppendColumn (Catalog.GetString ("Sets"), new CellRendererText(), "text", count++);
+       }
 
-       protected abstract TreeStore getStore(treeviewType type);
+       protected virtual TreeStore getStore(treeviewType type)
+       {
+               return new TreeStore(typeof (string), typeof (string), typeof (string), typeof (string)); 
//person, sex, exercise, sets
+       }
 }
 
 public class EncoderOverviewWindow : OverviewWindow
@@ -80,8 +91,8 @@ public class EncoderOverviewWindow : OverviewWindow
        {
                Glade.XML gladeXML;
                gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "overview.glade", "overview_win", 
null);
-
                gladeXML.Autoconnect(this);
+
                overview_win.Parent = parent;
 
                //put an icon to window
@@ -181,7 +192,6 @@ public class EncoderOverviewWindow : OverviewWindow
                EncoderOverviewWindowBox.overview_win.Hide();
                EncoderOverviewWindowBox = null;
        }
-
 }
 
 public class ForceSensorOverviewWindow : OverviewWindow
@@ -192,8 +202,8 @@ public class ForceSensorOverviewWindow : OverviewWindow
        {
                Glade.XML gladeXML;
                gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "overview.glade", "overview_win", 
null);
-
                gladeXML.Autoconnect(this);
+
                overview_win.Parent = parent;
 
                //put an icon to window
@@ -226,32 +236,70 @@ public class ForceSensorOverviewWindow : OverviewWindow
                return SqliteForceSensor.SelectSessionOverviewSets(false, sessionID);
        }
 
-       protected override void createTreeView(Gtk.TreeView tv, treeviewType type)
+       void on_button_close_clicked (object o, EventArgs args)
        {
-               tv.HeadersVisible=true;
-               int count = 0;
+               ForceSensorOverviewWindowBox.overview_win.Hide();
+               ForceSensorOverviewWindowBox = null;
+       }
 
-               tv.AppendColumn (Catalog.GetString ("Person"), new CellRendererText(), "text", count++);
-               tv.AppendColumn (Catalog.GetString ("Sex"), new CellRendererText(), "text", count++);
-               tv.AppendColumn (Catalog.GetString ("Exercise"), new CellRendererText(), "text", count++);
-               tv.AppendColumn (Catalog.GetString ("Sets"), new CellRendererText(), "text", count++);
+       void on_delete_event (object o, DeleteEventArgs args)
+       {
+               ForceSensorOverviewWindowBox.overview_win.Hide();
+               ForceSensorOverviewWindowBox = null;
        }
+}
 
-       protected override TreeStore getStore(treeviewType type)
+public class RunEncoderOverviewWindow : OverviewWindow
+{
+       static RunEncoderOverviewWindow RunEncoderOverviewWindowBox;
+
+       public RunEncoderOverviewWindow(Gtk.Window parent)
        {
-               return new TreeStore(typeof (string), typeof (string), typeof (string), typeof (string)); 
//person, sex, exercise, sets
+               Glade.XML gladeXML;
+               gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "overview.glade", "overview_win", 
null);
+               gladeXML.Autoconnect(this);
+
+               overview_win.Parent = parent;
+
+               //put an icon to window
+               UtilGtk.IconWindow(overview_win);
+       }
+
+       static public RunEncoderOverviewWindow Show (Gtk.Window parent, int sessionID)
+       {
+               if (RunEncoderOverviewWindowBox == null)
+                       RunEncoderOverviewWindowBox = new RunEncoderOverviewWindow (parent);
+
+               RunEncoderOverviewWindowBox.sessionID = sessionID;
+
+               RunEncoderOverviewWindowBox.initialize();
+
+               RunEncoderOverviewWindowBox.notebook.GetNthPage(1).Hide();
+
+               RunEncoderOverviewWindowBox.overview_win.Show ();
+
+               return RunEncoderOverviewWindowBox;
+       }
+
+       protected override string getTitle()
+       {
+               return Catalog.GetString("Force sensor overview");
+       }
+
+       protected override ArrayList selectData(treeviewType type)
+       {
+               return SqliteRunEncoder.SelectSessionOverviewSets(false, sessionID);
        }
 
        void on_button_close_clicked (object o, EventArgs args)
        {
-               ForceSensorOverviewWindowBox.overview_win.Hide();
-               ForceSensorOverviewWindowBox = null;
+               RunEncoderOverviewWindowBox.overview_win.Hide();
+               RunEncoderOverviewWindowBox = null;
        }
 
        void on_delete_event (object o, DeleteEventArgs args)
        {
-               ForceSensorOverviewWindowBox.overview_win.Hide();
-               ForceSensorOverviewWindowBox = null;
+               RunEncoderOverviewWindowBox.overview_win.Hide();
+               RunEncoderOverviewWindowBox = null;
        }
-
 }
diff --git a/src/gui/runEncoder.cs b/src/gui/runEncoder.cs
index 2dfd879f..84c2231a 100644
--- a/src/gui/runEncoder.cs
+++ b/src/gui/runEncoder.cs
@@ -1098,6 +1098,11 @@ LogB.Information(" re R ");
                        new DialogMessage(Constants.MessageTypes.WARNING, Constants.DirectoryCannotOpenStr());
        }
 
+       void on_menuitem_runEncoder_session_overview_activate (object o, EventArgs args)
+       {
+               RunEncoderOverviewWindow.Show (app1, currentSession.UniqueID);
+       }
+
        // -------------------------------- exercise stuff --------------------
 
 
diff --git a/src/sqlite/runEncoder.cs b/src/sqlite/runEncoder.cs
index a723f083..e2098af9 100644
--- a/src/sqlite/runEncoder.cs
+++ b/src/sqlite/runEncoder.cs
@@ -221,6 +221,41 @@ class SqliteRunEncoder : Sqlite
                return array;
        }
 
+       public static ArrayList SelectSessionOverviewSets (bool dbconOpened, int sessionID)
+       {
+               if(! dbconOpened)
+                       Sqlite.Open();
+
+               dbcmd.CommandText =
+                       "SELECT person77.name, person77.sex, runEncoderExercise.name, COUNT(*)" +
+                       " FROM person77, personSession77, runEncoderExercise, runEncoder" +
+                       " WHERE person77.uniqueID == runEncoder.personID AND personSession77.personID == 
runEncoder.personID AND personSession77.sessionID == runEncoder.sessionID AND 
runEncoderExercise.uniqueID==runEncoder.exerciseID AND runEncoder.sessionID == " + sessionID +
+                       " GROUP BY runEncoder.personID, exerciseID" +
+                       " ORDER BY person77.name";
+
+               LogB.SQL(dbcmd.CommandText.ToString());
+
+               SqliteDataReader reader;
+               reader = dbcmd.ExecuteReader();
+
+               ArrayList array = new ArrayList();
+               while(reader.Read())
+               {
+                       string [] s = {
+                               reader[0].ToString(),   //person name
+                               reader[1].ToString(),   //person sex
+                               reader[2].ToString(),   //exercise name
+                               reader[3].ToString()    //sets count
+                       };
+                       array.Add (s);
+               }
+
+               reader.Close();
+               if(! dbconOpened)
+                       Sqlite.Close();
+
+               return array;
+       }
 
        public static string DirToImport;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]