[chronojump] Encoder exercise can be edited



commit eac3d20585b4a86d898c4b803d08ac5f8152db29
Author: Xavier de Blas <xaviblas gmail com>
Date:   Mon Sep 15 17:14:18 2014 +0200

    Encoder exercise can be edited

 glade/chronojump.glade   |   63 +++++++++++++++++++++++++++++++++++++++++++--
 src/gui/encoder.cs       |   29 +++++++++++++--------
 src/gui/genericWindow.cs |    7 +++++
 src/sqlite/encoder.cs    |    7 +++--
 src/sqlite/main.cs       |    6 ++--
 5 files changed, 92 insertions(+), 20 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index aa482dc..6a6196b 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -6230,6 +6230,9 @@ Second Chronopic to platforms.</property>
                                                         <child>
                                                           <placeholder/>
                                                         </child>
+                                                        <child>
+                                                          <placeholder/>
+                                                        </child>
                                                       </widget>
                                                       <packing>
                                                         <property name="expand">True</property>
@@ -6876,6 +6879,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             </child>
                                                             <child>
@@ -7656,6 +7662,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">2</property>
@@ -8195,6 +8204,9 @@ Second Chronopic to platforms.</property>
                                                             <child>
                                                             <placeholder/>
                                                             </child>
+                                                            <child>
+                                                            <placeholder/>
+                                                            </child>
                                                             </widget>
                                                             <packing>
                                                             <property name="position">4</property>
@@ -12233,13 +12245,13 @@ on current Chronojump version.</property>
                                                             </packing>
                                                             </child>
                                                             <child>
-                                                            <widget class="GtkButton" 
id="button_encoder_exercise_info">
+                                                            <widget class="GtkButton" 
id="button_encoder_exercise_edit">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
                                                             <property name="receives_default">True</property>
                                                             <property name="has_tooltip">True</property>
-                                                            <property name="tooltip" translatable="yes">Show 
description of this exercise</property>
-                                                            <signal name="clicked" 
handler="on_button_encoder_exercise_info_clicked" swapped="no"/>
+                                                            <property name="tooltip" 
translatable="yes">Show/edit description of this exercise.</property>
+                                                            <signal name="clicked" 
handler="on_button_encoder_exercise_edit_clicked" swapped="no"/>
                                                             <child>
                                                             <widget class="GtkImage" id="image4">
                                                             <property name="visible">True</property>
@@ -17703,6 +17715,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -18150,6 +18165,9 @@ by you</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -19058,6 +19076,12 @@ by you</property>
             <child>
               <placeholder/>
             </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
           </widget>
           <packing>
             <property name="expand">True</property>
@@ -27116,6 +27140,24 @@ options</property>
                             <child>
                               <placeholder/>
                             </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
+                            <child>
+                              <placeholder/>
+                            </child>
                           </widget>
                         </child>
                       </widget>
@@ -28953,6 +28995,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                                 <child>
                                   <placeholder/>
                                 </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
                               </widget>
                             </child>
                           </widget>
@@ -29459,6 +29504,9 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                     </child>
                   </widget>
@@ -31938,6 +31986,9 @@ show elevation as:</property>
                         <child>
                           <placeholder/>
                         </child>
+                        <child>
+                          <placeholder/>
+                        </child>
                       </widget>
                       <packing>
                         <property name="left_attach">2</property>
@@ -32049,6 +32100,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
@@ -32175,6 +32229,9 @@ show elevation as:</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child>
+                      <placeholder/>
+                    </child>
                   </widget>
                 </child>
               </widget>
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index e156d53..712ab75 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -3121,7 +3121,8 @@ public partial class ChronoJumpWindow
        // ---------end of helpful methods -----------
 
 
-       void on_button_encoder_exercise_info_clicked (object o, EventArgs args) 
+       //info is now info and edit (all values can be changed), and detete (there's delete button)
+       void on_button_encoder_exercise_edit_clicked (object o, EventArgs args) 
        {
                EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(
                                false, getExerciseIDFromCombo(), false)[0];
@@ -3135,25 +3136,29 @@ public partial class ChronoJumpWindow
                ArrayList a5 = new ArrayList();
 
                //0 is the widgget to show; 1 is the editable; 2 id default value
-               a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(false); a1.Add(ex.name);
+               a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(true); a1.Add(ex.name);
                bigArray.Add(a1);
 
-               a2.Add(Constants.GenericWindowShow.SPININT); a2.Add(false); a2.Add("");
+               a2.Add(Constants.GenericWindowShow.SPININT); a2.Add(true); a2.Add("");
                bigArray.Add(a2);
                
-               a3.Add(Constants.GenericWindowShow.ENTRY2); a3.Add(false); a3.Add(ex.ressistance);
+               a3.Add(Constants.GenericWindowShow.ENTRY2); a3.Add(true); a3.Add(ex.ressistance);
                bigArray.Add(a3);
                
-               a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(false); a4.Add(ex.description);
+               a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(true); a4.Add(ex.description);
                bigArray.Add(a4);
                
-               a5.Add(Constants.GenericWindowShow.HBOXSPINDOUBLE2); a5.Add(true); a5.Add("");  //alowed to 
change
+               a5.Add(Constants.GenericWindowShow.HBOXSPINDOUBLE2); a5.Add(true); a5.Add("");
                bigArray.Add(a5);
                
                
                genericWin = GenericWindow.Show(false, Catalog.GetString("Encoder exercise name:"), bigArray);
                genericWin.LabelSpinInt = Catalog.GetString("Displaced body weight") + " (%)";
-               genericWin.SetSpinRange(ex.percentBodyWeight, ex.percentBodyWeight); //done this because 
IsEditable does not affect the cursors
+               
+               //genericWin.SetSpinRange(ex.percentBodyWeight, ex.percentBodyWeight); //done this because 
IsEditable does not affect the cursors
+               genericWin.SetSpinRange(0, 100);
+               genericWin.SetSpinValue(ex.percentBodyWeight);
+               
                genericWin.LabelEntry2 = Catalog.GetString("Resistance");
                genericWin.LabelEntry3 = Catalog.GetString("Description");
                genericWin.LabelSpinDouble2 = Catalog.GetString("Speed at 1RM");
@@ -3167,8 +3172,10 @@ public partial class ChronoJumpWindow
                genericWin.SetSpin3Range(ex.weightAngle,ex.weightAngle); //done this because IsEditable does 
not affect the cursors
                */
                genericWin.ShowButtonCancel(false);
+
+               genericWin.nameOld = ex.name;
                
-               genericWin.Button_accept.Clicked += new 
EventHandler(on_button_encoder_exercise_info_accepted);
+               genericWin.Button_accept.Clicked += new 
EventHandler(on_button_encoder_exercise_edit_accepted);
                genericWin.ShowNow();
        }
 
@@ -3224,9 +3231,9 @@ public partial class ChronoJumpWindow
                genericWin.ShowNow();
        }
        
-       void on_button_encoder_exercise_info_accepted (object o, EventArgs args) {
+       void on_button_encoder_exercise_edit_accepted (object o, EventArgs args) {
                encoder_exercise_edit(false);
-               genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_encoder_exercise_info_accepted);
+               genericWin.Button_accept.Clicked -= new 
EventHandler(on_button_encoder_exercise_edit_accepted);
        }
        void on_button_encoder_exercise_add_accepted (object o, EventArgs args) {
                encoder_exercise_edit(true);
@@ -3254,7 +3261,7 @@ public partial class ChronoJumpWindow
                                                Util.ConvertToPoint(genericWin.SpinDouble2Selected)
                                                );
                        else
-                               SqliteEncoder.UpdateExercise(false, name, genericWin.SpinIntSelected, 
+                               SqliteEncoder.UpdateExercise(false, genericWin.nameOld, name, 
genericWin.SpinIntSelected, 
                                                genericWin.Entry2Selected, genericWin.Entry3Selected,
                                                Util.ConvertToPoint(genericWin.SpinDouble2Selected)
                                                );
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index 10ca3fd..d9d5791 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -102,6 +102,9 @@ public class GenericWindow
        public int TreeviewSelectedUniqueID;
        private int commentColumn;
 
+       //used on encoder edit exercise
+       public string nameOld;
+
        public GenericWindow ()
        {
                Glade.XML gladeXML;
@@ -183,21 +186,25 @@ public class GenericWindow
                if(stuff == Constants.GenericWindowShow.ENTRY) {
                        entry.Show();
                        entry.IsEditable = editable;
+                       entry.Sensitive = editable;
                        entry.Text = text;
                }
                else if(stuff == Constants.GenericWindowShow.ENTRY2) {
                        hbox_entry2.Show();
                        entry2.IsEditable = editable;
+                       entry2.Sensitive = editable;
                        entry2.Text = text;
                }
                else if(stuff == Constants.GenericWindowShow.ENTRY3) {
                        hbox_entry3.Show();
                        entry3.IsEditable = editable;
+                       entry3.Sensitive = editable;
                        entry3.Text = text;
                }
                else if(stuff == Constants.GenericWindowShow.SPININT) {
                        hbox_spin_int.Show();
                        spin_int.IsEditable = editable;
+                       spin_int.Sensitive = editable;
                }
                else if(stuff == Constants.GenericWindowShow.SPINDOUBLE) {
                        spin_double.Show();
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index ae6a6e7..fe1ccb3 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -528,18 +528,19 @@ class SqliteEncoder : Sqlite
                }
        }
 
-       public static void UpdateExercise(bool dbconOpened, string name, int percentBodyWeight, 
+       public static void UpdateExercise(bool dbconOpened, string nameOld, string name, int 
percentBodyWeight, 
                        string ressistance, string description, string speed1RM)
        {
                if(! dbconOpened)
                        dbcon.Open();
 
                dbcmd.CommandText = "UPDATE " + Constants.EncoderExerciseTable + " SET " +
-                               " percentBodyWeight = " + percentBodyWeight +
+                               " name = '" + name +
+                               "', percentBodyWeight = " + percentBodyWeight +
                                ", ressistance = '" + ressistance +
                                "', description = '" + description +
                                "', future1 = '" + speed1RM +
-                               "' WHERE name = '" + name + "'" ;
+                               "' WHERE name = '" + nameOld + "'" ;
 
                Log.WriteLine(dbcmd.CommandText.ToString());
                dbcmd.ExecuteNonQuery();
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 68a0832..e1cf02c 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -1237,7 +1237,7 @@ class Sqlite
                        if(currentVersion == "0.90") {
                                dbcon.Open();
                                
-                               SqliteEncoder.UpdateExercise(true, "Squat", 100, "weight bar", "", ""); 
+                               SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", "", 
"");        
                                Log.WriteLine("Encoder Squat 75% -> 100%");
                                
                                SqlitePreferences.Update ("databaseVersion", "0.91", true); 
@@ -1259,8 +1259,8 @@ class Sqlite
                        if(currentVersion == "0.92") {
                                dbcon.Open();
                                
-                               SqliteEncoder.UpdateExercise(true, "Bench press", 0, "weight bar", 
"","0.185");
-                               SqliteEncoder.UpdateExercise(true, "Squat", 100, "weight bar", "","0.31");
+                               SqliteEncoder.UpdateExercise(true, "Bench press", "Bench press", 0, "weight 
bar", "","0.185");
+                               SqliteEncoder.UpdateExercise(true, "Squat", "Squat", 100, "weight bar", 
"","0.31");
                                Log.WriteLine("Added speed1RM on encoder exercise");
                                
                                SqlitePreferences.Update ("databaseVersion", "0.93", true); 


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