[chronojump] ForceSensorElasticBands delete shows sessions with their captures
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] ForceSensorElasticBands delete shows sessions with their captures
- Date: Sat, 20 Jun 2020 17:53:21 +0000 (UTC)
commit 0295ec2b31a09b2af6b9716833f378519bd9ab53
Author: Xavier de Blas <xaviblas gmail com>
Date: Sat Jun 20 19:49:36 2020 +0200
ForceSensorElasticBands delete shows sessions with their captures
glade/force_sensor_elastic_bands.glade | 27 +++++++++++++++++---
src/gui/forceSensorElasticBands.cs | 14 ++++++++---
src/sqlite/forceSensor.cs | 46 ++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+), 6 deletions(-)
---
diff --git a/glade/force_sensor_elastic_bands.glade b/glade/force_sensor_elastic_bands.glade
index 6b442685..4f19623e 100644
--- a/glade/force_sensor_elastic_bands.glade
+++ b/glade/force_sensor_elastic_bands.glade
@@ -1038,10 +1038,31 @@
</packing>
</child>
<child>
- <widget class="GtkScrolledWindow" id="scrolled_window_treeview_delete">
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="height_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <child>
+ <widget class="GtkTextView" id="textview_delete">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">False</property>
+ <property name="cursor_visible">False</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolled_window_treeview_delete">
+ <property name="height_request">100</property>
+ <property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<widget class="GtkTreeView" id="treeview_delete">
@@ -1053,7 +1074,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -1067,7 +1088,7 @@ you will have to create again the elastic band.</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
diff --git a/src/gui/forceSensorElasticBands.cs b/src/gui/forceSensorElasticBands.cs
index a54d2b13..45e9051c 100644
--- a/src/gui/forceSensorElasticBands.cs
+++ b/src/gui/forceSensorElasticBands.cs
@@ -61,7 +61,8 @@ public class ForceSensorElasticBandsWindow
//second tab "delete confirm"
[Widget] Gtk.Image image_delete_confirm;
[Widget] Gtk.Image image_cancel_delete;
- [Widget] Gtk.TreeView treeview_delete;
+ //[Widget] Gtk.TreeView treeview_delete;
+ [Widget] Gtk.TextView textview_delete;
[Widget] Gtk.Image image_close;
[Widget] Gtk.Button button_close;
@@ -375,8 +376,15 @@ public class ForceSensorElasticBandsWindow
private void on_button_delete_clicked (object o, EventArgs args)
{
- //TODO: only if there are captures done with this
- notebook.CurrentPage = 2;
+ ForceSensorElasticBand fseb = getSelectedForceSensorElasticBand();
+ List<string> sessionsWithThisEB =
SqliteForceSensorElasticBand.SelectSessionNamesWithCapturesWithElasticBand (fseb.UniqueID);
+
+ if(sessionsWithThisEB.Count == 0)
+ on_button_delete_confirm_clicked (o, args);
+ else {
+ textview_delete.Buffer.Text = Util.ListStringToString(sessionsWithThisEB);
+ notebook.CurrentPage = 2;
+ }
}
private void on_button_cancel_delete_clicked (object o, EventArgs args)
{
diff --git a/src/sqlite/forceSensor.cs b/src/sqlite/forceSensor.cs
index 0bd2fdd4..a81aa6d3 100644
--- a/src/sqlite/forceSensor.cs
+++ b/src/sqlite/forceSensor.cs
@@ -813,6 +813,52 @@ class SqliteForceSensorElasticBand : Sqlite
return list_fseb;
}
+ public static List<string> SelectSessionNamesWithCapturesWithElasticBand (int elasticBandID)
+ {
+ Sqlite.Open();
+ dbcmd.CommandText =
+ "SELECT session.name, forceSensor.stiffnessString " +
+ "FROM session, forceSensor, forceSensorExercise " +
+ "WHERE forceSensor.sessionID = session.uniqueID " +
+ "AND forceSensor.exerciseID = forceSensorExercise.uniqueID " +
+ "AND forceSensorExercise.elastic = 1 " +
+ "AND forceSensorExercise.forceResultant = 1 " +
+ "ORDER BY session.name";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ List<string> sessionsWithThisEB = new List<string>();
+
+ while(reader.Read())
+ {
+ //if we already have this session on list, continue
+ string sessionName = reader[0].ToString();
+ foreach(string s in sessionsWithThisEB)
+ if(s == sessionName)
+ continue;
+
+ string stiffnessString = reader[1].ToString();
+ string [] stiffPairs = stiffnessString.Split(new char[] {';'});
+ foreach(string str in stiffPairs)
+ {
+ string [] strPair = str.Split(new char[] {'*'});
+ if(Util.IsNumber(strPair[0], false) && Convert.ToInt32(strPair[0]) ==
elasticBandID)
+ {
+ sessionsWithThisEB.Add(sessionName);
+ continue;
+ }
+ }
+ }
+
+ reader.Close();
+ Sqlite.Close();
+
+ return sessionsWithThisEB;
+ }
+
//stiffnessString is a parameter of forceSensor table
public static double GetStiffnessOfACapture (bool dbconOpened, string stiffnessString)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]