[chronojump] 701534 1RM window working
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] 701534 1RM window working
- Date: Mon, 17 Jun 2013 14:57:13 +0000 (UTC)
commit dcf20a289244edf4cd03b354f692ffcab986b6c8
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Jun 17 16:56:55 2013 +0200
701534 1RM window working
glade/chronojump.glade | 3 +-
src/constants.cs | 1 +
src/encoder.cs | 5 +++
src/gui/encoder.cs | 70 +++++++++++++++++++++++++++++++++++++++++++--
src/gui/genericWindow.cs | 42 ++++++++++++++++------------
5 files changed, 98 insertions(+), 23 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 74083c3..64626f9 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -12203,6 +12203,7 @@ on current Chronojump version.</property>
<property name="has_tooltip">True</property>
<property name="tooltip" translatable="yes">1RM
window</property>
<property
name="use_action_appearance">False</property>
+ <signal name="clicked"
handler="on_button_encoder_1RM_win_clicked" swapped="no"/>
<child>
<widget class="GtkImage" id="image31">
<property name="visible">True</property>
@@ -32524,7 +32525,7 @@ times</property>
<widget class="GtkWindow" id="splash_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="title" translatable="no">Chronojump</property>
+ <property name="title">Chronojump</property>
<property name="resizable">False</property>
<property name="window_position">center-always</property>
<property name="type_hint">splashscreen</property>
diff --git a/src/constants.cs b/src/constants.cs
index 8067335..6fdb2e0 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -602,6 +602,7 @@ public class Constants
public enum EncoderCheckFileOp { ANALYZE_EXPORT_ALL_CURVES, ANALYZE_SAVE_IMAGE, ANALYZE_SAVE_TABLE}
public enum Encoder1RMMethod { NONWEIGHTED, WEIGHTED, WEIGHTED2, WEIGHTED3 }
+ public enum ContextMenu { NONE, EDITDELETE, DELETE }
public enum DoubleContact {
FIRST, AVERAGE, LAST
diff --git a/src/encoder.cs b/src/encoder.cs
index 9812f66..90e689e 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -489,5 +489,10 @@ public class Encoder1RM
this.load1RM = load1RM;
}
+ public string [] ToStringArray() {
+ string [] s = { uniqueID.ToString(), load1RM.ToString() };
+ return s;
+ }
+
~Encoder1RM() {}
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 952df26..13a12da 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -322,6 +322,67 @@ public partial class ChronoJumpWindow
spin_encoder_1RM_percent.Value = 100 * findMassFromCombo(false) / load1RM;
}
+ void on_button_encoder_1RM_win_clicked (object o, EventArgs args) {
+ ArrayList array1RM = SqliteEncoder.Select1RM(
+ false, currentPerson.UniqueID, currentSession.UniqueID,
getExerciseIDFromCombo());
+
+ ArrayList dataPrint = new ArrayList();
+ foreach(Encoder1RM e1RM in array1RM) {
+ dataPrint.Add(e1RM.ToStringArray());
+ }
+
+ string [] columnsString = {
+ Catalog.GetString("ID"),
+ Catalog.GetString("Load 1RM")
+ };
+
+ ArrayList 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);
+
+ genericWin = GenericWindow.Show(false, //don't show now
+ string.Format(Catalog.GetString("Saved 1RM values of athlete {0} on this
session."),
+ currentPerson.Name) + "\n" +
+ Catalog.GetString("If you want to delete a row, right click on it.") + "\n",
+ bigArray);
+
+ genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
Constants.ContextMenu.DELETE);
+
+ //find all persons in current session
+ ArrayList personsPre =
SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID);
+ string [] persons = new String[personsPre.Count];
+ int count = 0;
+ foreach (Person p in personsPre)
+ persons[count++] = p.UniqueID.ToString() + ":" + p.Name;
+
+ genericWin.ShowButtonCancel(false);
+ genericWin.SetButtonAcceptSensitive(true);
+ genericWin.SetButtonCancelLabel(Catalog.GetString("Close"));
+ //manage selected, unselected curves
+ genericWin.Button_accept.Clicked += new
EventHandler(on_spin_encoder_extra_weight_value_changed);
+ genericWin.Button_row_delete.Clicked += new EventHandler(on_encoder_1RM_win_row_delete);
+
+ //used when we don't need to read data,
+ //and we want to ensure next window will be created at needed size
+ //genericWin.DestroyOnAccept=true;
+ //here is comented because we are going to read the checkboxes
+
+ genericWin.ShowNow();
+ }
+
+ protected void on_encoder_1RM_win_row_delete (object o, EventArgs args) {
+ Log.WriteLine("row delete at encoder 1RM");
+
+ int uniqueID = genericWin.TreeviewSelectedUniqueID;
+ Log.WriteLine(uniqueID.ToString());
+
+ Sqlite.Delete(false, Constants.Encoder1RMTable, Convert.ToInt32(uniqueID));
+ }
+
+
void calculeCurves() {
encoderTimeStamp = UtilDate.ToFile(DateTime.Now);
@@ -497,7 +558,7 @@ public partial class ChronoJumpWindow
Catalog.GetString("If you want to edit or delete a row, right click on it.")
+ "\n",
bigArray);
- genericWin.SetTreeview(columnsString, true, dataPrint, new ArrayList(), true);
+ genericWin.SetTreeview(columnsString, true, dataPrint, new ArrayList(),
Constants.ContextMenu.EDITDELETE);
genericWin.AddOptionsToComboCheckBoxesOptions(encoderExercisesNames);
genericWin.CreateComboCheckBoxes();
genericWin.MarkActiveCurves(checkboxes);
@@ -675,7 +736,7 @@ public partial class ChronoJumpWindow
string.Format(Catalog.GetString("Select persons to compare to {0}."),
currentPerson.Name), bigArray);
- genericWin.SetTreeview(columnsString, true, data, nonSensitiveRows,false);
+ genericWin.SetTreeview(columnsString, true, data, nonSensitiveRows,
Constants.ContextMenu.NONE);
genericWin.CreateComboCheckBoxes();
genericWin.MarkActiveCurves(checkboxes);
genericWin.ShowButtonCancel(false);
@@ -774,7 +835,7 @@ public partial class ChronoJumpWindow
dataConverted.Add(encPS.ToStringArray());
}
- genericWin.SetTreeview(columnsString, true, dataConverted, nonSensitiveRows,false);
+ genericWin.SetTreeview(columnsString, true, dataConverted, nonSensitiveRows,
Constants.ContextMenu.NONE);
genericWin.CreateComboCheckBoxes();
genericWin.MarkActiveCurves(checkboxes);
genericWin.ShowButtonCancel(false);
@@ -844,7 +905,7 @@ public partial class ChronoJumpWindow
currentPerson.Name) + "\n" +
Catalog.GetString("If you want to edit or delete a row, right click on it."),
bigArray);
- genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(), true);
+ genericWin.SetTreeview(columnsString, false, dataPrint, new ArrayList(),
Constants.ContextMenu.EDITDELETE);
//find all persons in current session
ArrayList personsPre =
SqlitePersonSession.SelectCurrentSessionPersons(currentSession.UniqueID);
@@ -2249,6 +2310,7 @@ Log.WriteLine(str);
string.Format(Catalog.GetString("Saved 1RM without displaced body weight: {0}
Kg."),
load1RMWithoutPerson);
+ encoder_change_displaced_weight_and_1RM ();
new DialogMessage(Constants.MessageTypes.INFO, myString);
}
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index 5edb79a..53603de 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -83,6 +83,7 @@ public class GenericWindow
static GenericWindow GenericWindowBox;
private TreeStore store;
+ private Constants.ContextMenu genericWinContextMenu;
//used to read data, see if it's ok, and print an error message.
//if all is ok, destroy it with HideAndNull()
@@ -381,7 +382,7 @@ public class GenericWindow
//data is an ArrayList of strings[], each string [] is a row, each of its strings is a column
public void SetTreeview(string [] columnsString, bool addCheckbox,
- ArrayList data, ArrayList myNonSensitiveRows, bool contextMenu)
+ ArrayList data, ArrayList myNonSensitiveRows, Constants.ContextMenu contextMenu)
{
//adjust window to be bigger
generic_window.Resizable = true;
@@ -395,15 +396,22 @@ public class GenericWindow
nonSensitiveRows = myNonSensitiveRows;
Log.WriteLine("aaaaaaaaaaaaaaaa1");
- foreach (string [] line in data)
+ foreach (string [] line in data) {
store.AppendValues (line);
+ Log.WriteLine(Util.StringArrayToString(line,"\n"));
+ }
Log.WriteLine("aaaaaaaaaaaaaaaa2");
+ genericWinContextMenu = contextMenu;
+
treeview.CursorChanged += on_treeview_cursor_changed;
- if(contextMenu) {
+ if(contextMenu == Constants.ContextMenu.EDITDELETE) {
button_row_edit = new Gtk.Button();
button_row_delete = new Gtk.Button();
treeview.ButtonReleaseEvent += on_treeview_button_release_event;
+ } else if(contextMenu == Constants.ContextMenu.DELETE) {
+ button_row_delete = new Gtk.Button();
+ treeview.ButtonReleaseEvent += on_treeview_button_release_event;
}
}
@@ -559,15 +567,7 @@ Log.WriteLine("aaaaaaaaaaaaaaaa2");
TreeModel model = treeview.Model;
if (e.Button == 3) {
TreeIter iter = new TreeIter();
- //TreeModel myModel = tv.Model;
if (tv.Selection.GetSelected (out model, out iter)) {
-/*
-Log.WriteLine((string) store.GetValue (iter, 0));
-//Log.WriteLine((string) store.GetValue (iter, 1));
-Log.WriteLine((string) store.GetValue (iter, 2));
-Log.WriteLine((string) store.GetValue (iter, 3));
-*/
- //TreeviewSelectedUniqueID = Convert.ToInt32((string) store.GetValue (iter,
0));
TreeviewSelectedUniqueID = Convert.ToInt32((string) store.GetValue (iter, 0));
treeviewContextMenu();
}
@@ -579,14 +579,20 @@ Log.WriteLine((string) store.GetValue (iter, 3));
Menu myMenu = new Menu ();
Gtk.MenuItem myItem;
- myItem = new MenuItem ( Catalog.GetString("Edit selected") );
- myItem.Activated += on_edit_selected_clicked;
- myMenu.Attach( myItem, 0, 1, 0, 1 );
-
+ if(genericWinContextMenu == Constants.ContextMenu.EDITDELETE) {
+ myItem = new MenuItem ( Catalog.GetString("Edit selected") );
+ myItem.Activated += on_edit_selected_clicked;
+ myMenu.Attach( myItem, 0, 1, 0, 1 );
- myItem = new MenuItem ( Catalog.GetString("Delete selected") );
- myItem.Activated += on_delete_selected_clicked;
- myMenu.Attach( myItem, 0, 1, 1, 2 );
+ myItem = new MenuItem ( Catalog.GetString("Delete selected") );
+ myItem.Activated += on_delete_selected_clicked;
+ myMenu.Attach( myItem, 0, 1, 1, 2 );
+ }
+ else if(genericWinContextMenu == Constants.ContextMenu.DELETE) {
+ myItem = new MenuItem ( Catalog.GetString("Delete selected") );
+ myItem.Activated += on_delete_selected_clicked;
+ myMenu.Attach( myItem, 0, 1, 0, 1 );
+ }
myMenu.Popup();
myMenu.ShowAll();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]