[chronojump] New feature: overview win can select person
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] New feature: overview win can select person
- Date: Wed, 22 Apr 2020 16:08:33 +0000 (UTC)
commit fb31404838dca4c6e82b026a6397fc4e5fd90071
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 22 18:08:04 2020 +0200
New feature: overview win can select person
glade/overview.glade | 76 +++++++++++++++++++++++++++++++++++-
src/gui/app1/chronojump.cs | 22 +++++++++--
src/gui/overview.cs | 96 +++++++++++++++++++++++++++++++++++++++++++---
src/sqlite/encoder.cs | 48 ++++++++++++-----------
src/sqlite/forceSensor.cs | 11 +++---
src/sqlite/runEncoder.cs | 11 +++---
6 files changed, 222 insertions(+), 42 deletions(-)
---
diff --git a/glade/overview.glade b/glade/overview.glade
index a3c581a8..62ecd92e 100644
--- a/glade/overview.glade
+++ b/glade/overview.glade
@@ -16,10 +16,82 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">8</property>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <widget class="GtkHBox" id="hbox_radio_sets_repetitions">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">20</property>
+ <child>
+ <widget class="GtkRadioButton" id="radio_sets">
+ <property name="label" translatable="yes">Sets</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <signal name="toggled" handler="on_radio_sets_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="radio_reps">
+ <property name="label" translatable="yes">Repetitions</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">radio_sets</property>
+ <signal name="toggled" handler="on_radio_reps_toggled" swapped="no"/>
+ </widget>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="button_select_this_person">
+ <property name="label" translatable="yes">Select this person</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </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="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<widget class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="show_tabs">False</property>
<child>
<widget class="GtkScrolledWindow" id="scr_treeview_sets">
<property name="visible">True</property>
@@ -78,7 +150,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
<child>
@@ -113,7 +185,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
</widget>
diff --git a/src/gui/app1/chronojump.cs b/src/gui/app1/chronojump.cs
index b08c4ad8..825a5229 100644
--- a/src/gui/app1/chronojump.cs
+++ b/src/gui/app1/chronojump.cs
@@ -2602,6 +2602,7 @@ public partial class ChronoJumpWindow
}
}
+ private OverviewWindow overviewWin;
private void on_session_overview_clicked (object o, EventArgs args)
{
if (currentSession == null)
@@ -2610,11 +2611,26 @@ public partial class ChronoJumpWindow
Constants.Menuitem_modes m = current_menuitem_mode;
if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m ==
Constants.Menuitem_modes.POWERINERTIAL)
- EncoderOverviewWindow.Show (app1, currentEncoderGI, currentSession.UniqueID);
+ {
+ overviewWin = EncoderOverviewWindow.Show (app1, currentEncoderGI,
currentSession.UniqueID);
+ }
else if(m == Constants.Menuitem_modes.FORCESENSOR)
- ForceSensorOverviewWindow.Show (app1, currentSession.UniqueID);
+ overviewWin = ForceSensorOverviewWindow.Show (app1, currentSession.UniqueID);
else if(m == Constants.Menuitem_modes.RUNSENCODER)
- RunEncoderOverviewWindow.Show (app1, currentSession.UniqueID);
+ overviewWin = RunEncoderOverviewWindow.Show (app1, currentSession.UniqueID);
+
+ overviewWin.Button_select_this_person.Clicked -= new EventHandler(on_overview_select_person);
+ overviewWin.Button_select_this_person.Clicked += new EventHandler(on_overview_select_person);
+ }
+
+ private void on_overview_select_person (object o, EventArgs args)
+ {
+ if(overviewWin.SelectedPersonID != -1)
+ {
+ //LogB.Information("selected: " + overviewWin.SelectedPersonID.ToString());
+ selectRowTreeView_persons(treeview_persons,
+ myTreeViewPersons.FindRow(overviewWin.SelectedPersonID));
+ }
}
private void on_export_session_accepted(object o, EventArgs args) {
diff --git a/src/gui/overview.cs b/src/gui/overview.cs
index 6412a8ea..7abab54e 100644
--- a/src/gui/overview.cs
+++ b/src/gui/overview.cs
@@ -32,13 +32,20 @@ public abstract class OverviewWindow
[Widget] protected Gtk.TreeView treeview_sets;
[Widget] protected Gtk.TreeView treeview_reps;
[Widget] protected Gtk.Notebook notebook;
+ [Widget] protected Gtk.HBox hbox_radio_sets_repetitions;
+ [Widget] protected Gtk.RadioButton radio_sets;
+ [Widget] protected Gtk.RadioButton radio_reps;
+ [Widget] protected Gtk.Button button_select_this_person;
protected enum treeviewType { SETS, REPS }
protected int sessionID;
+ protected int selectedPersonID;
protected void initialize()
{
setTitle();
+ button_select_this_person.Sensitive = false;
+ selectedPersonID = -1;
createTreeViews();
}
@@ -63,6 +70,8 @@ public abstract class OverviewWindow
foreach (string [] line in array)
store.AppendValues (line);
+
+ tv.CursorChanged += on_treeview_cursor_changed;
}
protected virtual void createTreeView(Gtk.TreeView tv, treeviewType type)
@@ -70,16 +79,85 @@ public abstract class OverviewWindow
tv.HeadersVisible=true;
int count = 0;
+ //add invisible personID column
+ Gtk.TreeViewColumn personIDCol = new Gtk.TreeViewColumn ("personId", new CellRendererText(),
"text", count++);
+ personIDCol.Visible = false;
+ tv.AppendColumn(personIDCol);
+
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 void on_treeview_cursor_changed (object o, EventArgs args)
+ {
+ TreeIter iter = new TreeIter();
+
+ if (o == (object) treeview_sets)
+ {
+ TreeModel myModel = treeview_sets.Model;
+
+ if (treeview_sets.Selection.GetSelected (out myModel, out iter))
+ {
+ button_select_this_person.Sensitive = true;
+ string selected = ( treeview_sets.Model.GetValue (iter, 0) ).ToString();
+ if(Util.IsNumber(selected, false))
+ selectedPersonID = Convert.ToInt32(selected);
+ }
+ } else if (o == (object) treeview_reps)
+ {
+ TreeModel myModel = treeview_reps.Model;
+
+ if (treeview_reps.Selection.GetSelected (out myModel, out iter))
+ {
+ button_select_this_person.Sensitive = true;
+ string selected = ( treeview_reps.Model.GetValue (iter, 0) ).ToString();
+ if(Util.IsNumber(selected, false))
+ selectedPersonID = Convert.ToInt32(selected);
+ }
+ }
+ }
+
+ protected void on_radio_sets_toggled (object o, EventArgs args)
+ {
+ if(radio_sets.Active)
+ notebook.CurrentPage = 0;
+
+ //unselect to have no confusion on which person is selected by button_select_this_person
+ //if there are different selections on both treeviews
+ treeview_reps.Selection.UnselectAll();
+ treeview_sets.Selection.UnselectAll();
+ button_select_this_person.Sensitive = false;
+ }
+
+ protected void on_radio_reps_toggled (object o, EventArgs args)
+ {
+ if(radio_reps.Active)
+ notebook.CurrentPage = 1;
+
+ //unselect to have no confusion on which person is selected by button_select_this_person
+ //if there are different selections on both treeviews
+ treeview_reps.Selection.UnselectAll();
+ treeview_sets.Selection.UnselectAll();
+ button_select_this_person.Sensitive = false;
+ }
+
protected virtual TreeStore getStore(treeviewType type)
{
- return new TreeStore(typeof (string), typeof (string), typeof (string), typeof (string));
//person, sex, exercise, sets
+ return new TreeStore(typeof (string), typeof (string), typeof (string), typeof (string),
typeof (string)); //personID (hidden), person name, sex, exercise, sets
}
+
+ public Button Button_select_this_person
+ {
+ set { button_select_this_person = value; }
+ get { return button_select_this_person; }
+ }
+ public int SelectedPersonID
+ {
+ get { return selectedPersonID; }
+ }
+
}
public class EncoderOverviewWindow : OverviewWindow
@@ -108,6 +186,7 @@ public class EncoderOverviewWindow : OverviewWindow
EncoderOverviewWindowBox.sessionID = sessionID;
EncoderOverviewWindowBox.initialize();
+ EncoderOverviewWindowBox.hbox_radio_sets_repetitions.Visible = true;
EncoderOverviewWindowBox.overview_win.Show ();
@@ -142,6 +221,11 @@ public class EncoderOverviewWindow : OverviewWindow
tv.HeadersVisible=true;
int count = 0;
+ //add invisible personID column
+ Gtk.TreeViewColumn personIDCol = new Gtk.TreeViewColumn ("personId", new CellRendererText(),
"text", count++);
+ personIDCol.Visible = false;
+ tv.AppendColumn(personIDCol);
+
if(type == treeviewType.SETS)
{
tv.AppendColumn (Catalog.GetString ("Person"), new CellRendererText(), "text",
count++);
@@ -168,14 +252,14 @@ public class EncoderOverviewWindow : OverviewWindow
if(type == treeviewType.SETS)
{
if(encoderGI == Constants.EncoderGI.GRAVITATORY)
- s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof(string)); //person, sex, exercise, displaced mass, sets
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof (string), typeof(string)); //personID (hidden), person name, sex, exercise, displaced mass,
sets
else
- s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string)); //person, sex, exercise, sets
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof (string)); //personID (hidden), person name, sex, exercise, sets
} else {
if(encoderGI == Constants.EncoderGI.GRAVITATORY)
- s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof(string)); //person, sex, exercise, extra mass, power
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof (string), typeof(string)); //personID (hidden), person name, sex, exercise, extra mass, power
else
- s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string)); //person, sex, exercise, power
+ s = new TreeStore(typeof (string), typeof (string), typeof (string), typeof
(string), typeof (string)); //personID (hidden), person name, sex, exercise, power
}
return s;
@@ -219,6 +303,7 @@ public class ForceSensorOverviewWindow : OverviewWindow
ForceSensorOverviewWindowBox.initialize();
+ ForceSensorOverviewWindowBox.hbox_radio_sets_repetitions.Visible = false;;
ForceSensorOverviewWindowBox.notebook.GetNthPage(1).Hide();
ForceSensorOverviewWindowBox.overview_win.Show ();
@@ -274,6 +359,7 @@ public class RunEncoderOverviewWindow : OverviewWindow
RunEncoderOverviewWindowBox.initialize();
+ RunEncoderOverviewWindowBox.hbox_radio_sets_repetitions.Visible = false;;
RunEncoderOverviewWindowBox.notebook.GetNthPage(1).Hide();
RunEncoderOverviewWindowBox.overview_win.Show ();
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index 4ceca281..d5c4ea46 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -475,7 +475,7 @@ class SqliteEncoder : Sqlite
Sqlite.Open();
dbcmd.CommandText =
- "SELECT person77.name, person77.sex, encoder.encoderConfiguration,
encoderExercise.name, (personSession77.weight * encoderExercise.percentBodyWeight/100) + encoder.extraWeight,
COUNT(*)" +
+ "SELECT person77.uniqueID, person77.name, person77.sex, encoder.encoderConfiguration,
encoderExercise.name, (personSession77.weight * encoderExercise.percentBodyWeight/100) + encoder.extraWeight,
COUNT(*)" +
" FROM person77, personSession77, encoderExercise, encoder" +
" WHERE person77.uniqueID == encoder.personID AND personSession77.personID ==
encoder.personID AND personSession77.sessionID == encoder.sessionID AND
encoderExercise.uniqueID==encoder.exerciseID AND signalOrCurve == \"signal\" AND encoder.sessionID == " +
sessionID +
" GROUP BY encoder.personID, exerciseID, extraWeight" +
@@ -490,7 +490,7 @@ class SqliteEncoder : Sqlite
while(reader.Read())
{
//discard if != encoderGI
- string [] strFull = reader[2].ToString().Split(new char[] {':'});
+ string [] strFull = reader[3].ToString().Split(new char[] {':'});
EncoderConfiguration econf = new EncoderConfiguration(
(Constants.EncoderConfigurationNames)
Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
@@ -504,19 +504,21 @@ class SqliteEncoder : Sqlite
if(encoderGI == Constants.EncoderGI.GRAVITATORY)
{
string [] s = {
- reader[0].ToString(), //person name
- reader[1].ToString(), //person sex
- reader[3].ToString(), //encoder exercise name
- reader[4].ToString(), //displaced mass (includes percentBodyeight)
- reader[5].ToString() //sets count
+ reader[0].ToString(), //person uniqueID
+ reader[1].ToString(), //person name
+ reader[2].ToString(), //person sex
+ reader[4].ToString(), //encoder exercise name
+ reader[5].ToString(), //displaced mass (includes percentBodyeight)
+ reader[6].ToString() //sets count
};
array.Add (s);
} else {
string [] s = {
- reader[0].ToString(), //person name
- reader[1].ToString(), //person sex
- reader[3].ToString(), //encoder exercise name
- reader[5].ToString() //sets count
+ reader[0].ToString(), //person uniqueID
+ reader[1].ToString(), //person name
+ reader[2].ToString(), //person sex
+ reader[4].ToString(), //encoder exercise name
+ reader[6].ToString() //sets count
};
array.Add (s);
}
@@ -535,7 +537,7 @@ class SqliteEncoder : Sqlite
Sqlite.Open();
dbcmd.CommandText =
- "SELECT person77.name, person77.sex, encoder.encoderConfiguration,
encoderExercise.name, encoder.extraWeight, encoder.future1 " + //TODO: future2, future3
+ "SELECT person77.uniqueID, person77.name, person77.sex, encoder.encoderConfiguration,
encoderExercise.name, encoder.extraWeight, encoder.future1 " + //TODO: future2, future3
"FROM person77, encoderExercise, encoder " +
"WHERE sessionID = " + sessionID.ToString() +
" AND signalOrCurve = \"curve\" " +
@@ -552,7 +554,7 @@ class SqliteEncoder : Sqlite
while(reader.Read())
{
//discard if != encoderGI
- string [] strFull = reader[2].ToString().Split(new char[] {':'});
+ string [] strFull = reader[3].ToString().Split(new char[] {':'});
EncoderConfiguration econf = new EncoderConfiguration(
(Constants.EncoderConfigurationNames)
Enum.Parse(typeof(Constants.EncoderConfigurationNames), strFull[0]) );
@@ -566,20 +568,22 @@ class SqliteEncoder : Sqlite
if(encoderGI == Constants.EncoderGI.GRAVITATORY)
{
string [] s = {
- reader[0].ToString(), //person name
- reader[1].ToString(), //person sex
- reader[3].ToString(), //encoder exercise name
- Util.ChangeDecimalSeparator(reader[4].ToString()), //extra mass
- reader[5].ToString() //power
+ reader[0].ToString(), //person uniqueID
+ reader[1].ToString(), //person name
+ reader[2].ToString(), //person sex
+ reader[4].ToString(), //encoder exercise name
+ Util.ChangeDecimalSeparator(reader[5].ToString()), //extra mass
+ reader[6].ToString() //power
//TODO: speed, force
};
array.Add (s);
} else {
string [] s = {
- reader[0].ToString(), //person name
- reader[1].ToString(), //person sex
- reader[3].ToString(), //encoder exercise name
- reader[5].ToString() //power
+ reader[0].ToString(), //person uniqueID
+ reader[1].ToString(), //person name
+ reader[2].ToString(), //person sex
+ reader[4].ToString(), //encoder exercise name
+ reader[6].ToString() //power
//TODO: speed, force
};
array.Add (s);
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index 2dcefa1c..0bd2fdd4 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -236,7 +236,7 @@ class SqliteForceSensor : Sqlite
Sqlite.Open();
dbcmd.CommandText =
- "SELECT person77.name, person77.sex, forceSensorExercise.name, COUNT(*)" +
+ "SELECT person77.uniqueID, person77.name, person77.sex, forceSensorExercise.name,
COUNT(*)" +
" FROM person77, personSession77, forceSensorExercise, forceSensor" +
" WHERE person77.uniqueID == forceSensor.personID AND personSession77.personID ==
forceSensor.personID AND personSession77.sessionID == forceSensor.sessionID AND
forceSensorExercise.uniqueID==forceSensor.exerciseID AND forceSensor.sessionID == " + sessionID +
" GROUP BY forceSensor.personID, exerciseID" +
@@ -251,10 +251,11 @@ class SqliteForceSensor : Sqlite
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
+ reader[0].ToString(), //personID
+ reader[1].ToString(), //person name
+ reader[2].ToString(), //person sex
+ reader[3].ToString(), //exercise name
+ reader[4].ToString() //sets count
};
array.Add (s);
}
diff --git a/src/sqlite/runEncoder.cs b/src/sqlite/runEncoder.cs
index 328ed4e0..e0becd6e 100644
--- a/src/sqlite/runEncoder.cs
+++ b/src/sqlite/runEncoder.cs
@@ -227,7 +227,7 @@ class SqliteRunEncoder : Sqlite
Sqlite.Open();
dbcmd.CommandText =
- "SELECT person77.name, person77.sex, runEncoderExercise.name, COUNT(*)" +
+ "SELECT person77.uniqueID, 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" +
@@ -242,10 +242,11 @@ class SqliteRunEncoder : Sqlite
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
+ reader[0].ToString(), //personID
+ reader[1].ToString(), //person name
+ reader[2].ToString(), //person sex
+ reader[3].ToString(), //exercise name
+ reader[4].ToString() //sets count
};
array.Add (s);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]