[chronojump] Encoder export CSV latin / british



commit 91504217f612d78641983c6f6411db9a9e72b669
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 14 17:25:45 2014 +0100

    Encoder export CSV latin / british

 glade/chronojump.glade    |    6 +++---
 src/constants.cs          |    3 ++-
 src/gui/chronojump.cs     |    7 ++++++-
 src/gui/encoder.cs        |    8 ++++----
 src/gui/preferences.cs    |   20 ++++++++++++++++++--
 src/sqlite/main.cs        |   17 +++++++++++++++--
 src/sqlite/preferences.cs |    3 ++-
 src/util.cs               |    5 +++--
 8 files changed, 53 insertions(+), 16 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 7474632..fdd7051 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -27447,7 +27447,7 @@ show elevation as:</property>
                         <property name="can_focus">False</property>
                         <property name="spacing">6</property>
                         <child>
-                          <widget class="GtkRadioButton" id="radiobutton_export_latin">
+                          <widget class="GtkRadioButton" id="radio_export_latin">
                             <property name="label" translatable="yes">Latin</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
@@ -27486,14 +27486,14 @@ show elevation as:</property>
                         <property name="can_focus">False</property>
                         <property name="spacing">6</property>
                         <child>
-                          <widget class="GtkRadioButton" id="radiobutton_export_non-latin">
+                          <widget class="GtkRadioButton" id="radio_export_non_latin">
                             <property name="label" translatable="yes">Non-Latin</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">True</property>
-                            <property name="group">radiobutton_export_latin</property>
+                            <property name="group">radio_export_latin</property>
                           </widget>
                           <packing>
                             <property name="expand">False</property>
diff --git a/src/constants.cs b/src/constants.cs
index fedbd92..9a2e58b 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -198,7 +198,8 @@ public class Constants
        public static string TakeOffWeightName = "TakeOffWeight"; //translate (take off?)
 
 
-       public static string SpreadsheetString = "\n\n" + Catalog.GetString("When import from your 
spreadsheet (OpenOffice, R, MS Excel, ...)\nremember the separator character is semicolon <b>;</b>, or comma 
<b>,</b>.");
+       public static string SpreadsheetString = "\n\n" + Catalog.GetString("When import from your 
spreadsheet (OpenOffice, R, MS Excel, ...)\nremember the separator character is semicolon <b>;</b>, or comma 
<b>,</b>.") + 
+                       "\n\n" + Catalog.GetString("This can be changed on preferences.");
 
 /*     OLD, check this
        public static string PotencyLewisCMJFormula = Catalog.GetString("Peak Power")+ " CMJ (Lewis) " +
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 14cc9b7..0db10f2 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -311,6 +311,7 @@ public partial class ChronoJumpWindow
        private static bool weightPercentPreferred;
        private static bool heightPreferred;
        private static bool metersSecondsPreferred;
+       private static string CSVExportDecimalSeparator; //"COMMA" or "POINT"
 
        private static Person currentPerson;
        private static Session currentSession;
@@ -905,6 +906,7 @@ public partial class ChronoJumpWindow
                encoderSmoothCon = Convert.ToDouble ( Util.ChangeDecimalSeparator (
                                SqlitePreferences.Select("encoderSmoothCon") ) );
 
+               CSVExportDecimalSeparator = SqlitePreferences.Select("CSVExportDecimalSeparator");
 
                //change language works on windows. On Linux let's change the locale
                //if(UtilAll.IsWindows())
@@ -2619,7 +2621,8 @@ public partial class ChronoJumpWindow
                                //System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(),
                                SqlitePreferences.Select("language"),
                                encoderPropulsive, encoderSmoothCon,
-                               videoDevices, videoDeviceNum, SqlitePreferences.Select("encoder1RMMethod")
+                               videoDevices, videoDeviceNum, SqlitePreferences.Select("encoder1RMMethod"),
+                               CSVExportDecimalSeparator 
                                );
                myWin.Button_accept.Clicked += new EventHandler(on_preferences_accepted);
        }
@@ -2703,6 +2706,8 @@ public partial class ChronoJumpWindow
                encoderPropulsive = SqlitePreferences.Select("encoderPropulsive") == "True"; 
                encoderSmoothCon = Convert.ToDouble ( Util.ChangeDecimalSeparator (
                                SqlitePreferences.Select("encoderSmoothCon") ) );
+               
+               CSVExportDecimalSeparator = SqlitePreferences.Select("CSVExportDecimalSeparator");
 
                videoDeviceNum = Convert.ToInt32(SqlitePreferences.Select("videoDevice"));
                if(checkbutton_video.Active) {
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index 24a0f13..37802a1 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -663,7 +663,7 @@ public partial class ChronoJumpWindow
                                Util.ConvertToPoint(encoderSmoothCon),                  //R decimal: '.'
                                0,                      //curve is not used here
                                image_encoder_width, image_encoder_height,
-                               Util.GetDecimalSeparator()
+                               CSVExportDecimalSeparator 
                                );
 
                //capturingRotaryInertial = false;
@@ -1239,7 +1239,7 @@ public partial class ChronoJumpWindow
                                -1,
                                image_encoder_width,
                                image_encoder_height,
-                               Util.GetDecimalSeparator()
+                               CSVExportDecimalSeparator 
                                );
 
                string dataFileName = UtilEncoder.GetEncoderDataTempFileName();
@@ -2117,7 +2117,7 @@ public partial class ChronoJumpWindow
                                        myCurveNum,
                                        image_encoder_width, 
                                        image_encoder_height,
-                                       Util.GetDecimalSeparator()
+                                       CSVExportDecimalSeparator 
                                        );
 
 
@@ -2227,7 +2227,7 @@ Log.WriteLine(str);
                                        
Convert.ToInt32(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo)),
                                        image_encoder_width,
                                        image_encoder_height,
-                                       Util.GetDecimalSeparator()
+                                       CSVExportDecimalSeparator 
                                        );
                        
                        dataFileName = UtilEncoder.GetEncoderDataTempFileName();
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 23cd63b..f2f6f7e 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2011   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2014   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -67,6 +67,9 @@ public class PreferencesWindow {
        [Widget] Gtk.RadioButton radio_encoder_1RM_weighted;
        [Widget] Gtk.RadioButton radio_encoder_1RM_weighted2;
        [Widget] Gtk.RadioButton radio_encoder_1RM_weighted3;
+                       
+       [Widget] Gtk.RadioButton radio_export_latin;
+       [Widget] Gtk.RadioButton radio_export_non_latin;
 
 //     [Widget] Gtk.Box hbox_language_row;
 //     [Widget] Gtk.Box hbox_combo_language;
@@ -105,7 +108,8 @@ public class PreferencesWindow {
                        bool showInitialSpeed, bool showAngle, bool showQIndex, bool showDjIndex,
                        bool askDeletion, bool weightStatsPercent, bool heightPreferred, bool 
metersSecondsPreferred, 
                        string language, bool encoderPropulsive, double encoderSmoothCon,
-                       string [] videoDevices, int videoDeviceNum, string encoder1RMMethod)
+                       string [] videoDevices, int videoDeviceNum, string encoder1RMMethod,
+                       string CSVExportDecimalSeparator)
        {
                if (PreferencesWindowBox == null) {
                        PreferencesWindowBox = new PreferencesWindow ();
@@ -183,6 +187,13 @@ public class PreferencesWindow {
                        PreferencesWindowBox.radio_speed_ms.Active = true; 
                else 
                        PreferencesWindowBox.radio_speed_km.Active = true; 
+
+
+               if(CSVExportDecimalSeparator == "COMMA")
+                       PreferencesWindowBox.radio_export_latin.Active = true; 
+               else
+                       PreferencesWindowBox.radio_export_non_latin.Active = true; 
+
        
                //encoder       
                PreferencesWindowBox.checkbutton_encoder_propulsive.Active = encoderPropulsive;
@@ -423,6 +434,11 @@ public class PreferencesWindow {
                SqlitePreferences.Update("encoderSmoothCon", Util.ConvertToPoint( 
                                (double) PreferencesWindowBox.spin_encoder_smooth_con.Value), true);
                SqlitePreferences.Update("videoDevice", UtilGtk.ComboGetActivePos(combo_camera).ToString(), 
true);
+               
+               if(PreferencesWindowBox.radio_export_latin.Active)
+                       SqlitePreferences.Update("CSVExportDecimalSeparator","COMMA", true); 
+               else
+                       SqlitePreferences.Update("CSVExportDecimalSeparator","POINT", true); 
        
                string encoder1RMMethod = "";   
                if(PreferencesWindowBox.radio_encoder_1RM_nonweighted.Active)
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index aec1d7a..4d691a9 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2012   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2014   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -74,7 +74,7 @@ class Sqlite
         * Important, change this if there's any update to database
         * Important2: if database version get numbers higher than 1, check if the comparisons with 
currentVersion works ok
         */
-       static string lastChronojumpDatabaseVersion = "1.00";
+       static string lastChronojumpDatabaseVersion = "1.01";
 
        public Sqlite() {
        }
@@ -1390,6 +1390,18 @@ class Sqlite
 
                                currentVersion = "1.00";
                        }
+                       if(currentVersion == "1.00") {
+                               dbcon.Open();
+                       
+                               SqlitePreferences.Insert ("CSVExportDecimalSeparator", 
Util.GetDecimalSeparatorFromLocale());
+
+                               Log.WriteLine("Added export to CSV configuration on preferences");
+                               SqlitePreferences.Update ("databaseVersion", "1.01", true); 
+                               dbcon.Close();
+
+                               currentVersion = "1.01";
+                       }
+
                                
                }
 
@@ -1530,6 +1542,7 @@ class Sqlite
                SqliteCountry.initialize();
                
                //changes [from - to - desc]
+               //1.00 - 1.01 Converted DB to 1.01 Added export to CSV configuration on preferences
                //0.99 - 1.00 Converted DB to 1.00 Encoder added Free and Inclinated Exercises
                //0.98 - 0.99 Converted DB to 0.99 Encoder table improved 
                //0.97 - 0.98 Converted DB to 0.98 Fixed encoder laterality
diff --git a/src/sqlite/preferences.cs b/src/sqlite/preferences.cs
index 30fa71a..42426e5 100644
--- a/src/sqlite/preferences.cs
+++ b/src/sqlite/preferences.cs
@@ -15,7 +15,7 @@
  *  along with this program; if not, write to the Free Software
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Copyright (C) 2004-2009   Xavier de Blas <xaviblas gmail com> 
+ * Copyright (C) 2004-2014   Xavier de Blas <xaviblas gmail com> 
  */
 
 using System;
@@ -77,6 +77,7 @@ class SqlitePreferences : Sqlite
                Insert ("videoDevice", "0"); //first
                Insert ("encoder1RMMethod", Constants.Encoder1RMMethod.WEIGHTED2.ToString());
                Insert ("inertialmomentum", "0.01");
+               Insert ("CSVExportDecimalSeparator", Util.GetDecimalSeparatorFromLocale());
        }
 
        public static void Insert(string myName, string myValue)
diff --git a/src/util.cs b/src/util.cs
index 1aba68b..b377441 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -59,8 +59,9 @@ public class Util
                return myStringBuilder.ToString();
        }
        
-       //used to send to R and export csv there
-       public static string GetDecimalSeparator() {
+       //this is only used to define a preferences configuration
+       //to send to R and export csv,  gui/encoder.cs uses CSVExportDecimalSeparator variable that is read 
from preferences SQL
+       public static string GetDecimalSeparatorFromLocale() {
                System.Globalization.NumberFormatInfo localeInfo = new 
System.Globalization.NumberFormatInfo();
                localeInfo = System.Globalization.NumberFormatInfo.CurrentInfo;
 


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