[chronojump] comboSelectRunsI done!
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] comboSelectRunsI done!
- Date: Sat, 8 Oct 2016 23:22:47 +0000 (UTC)
commit fc57383ad34c4bb0da26ca69a89157444002cbd2
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Oct 9 01:20:12 2016 +0200
comboSelectRunsI done!
src/gui/chronojump.cs | 47 +++++++++++++++---------------------------
src/gui/cjCombo.cs | 21 +++++++++++++++++++
src/gui/run.cs | 9 +++----
src/sqlite/runType.cs | 46 ++++++++++++++++++++++++++++++++++++++++++
src/sqlite/usefulObjects.cs | 27 ++++++++++++++++++++++++
5 files changed, 115 insertions(+), 35 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index e3fae8c..c9fec6b 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -170,6 +170,7 @@ public partial class ChronoJumpWindow
CjComboSelectJumps comboSelectJumps;
CjComboSelectJumpsRj comboSelectJumpsRj;
CjComboSelectRuns comboSelectRuns;
+ CjComboSelectRunsI comboSelectRunsI;
[Widget] Gtk.ComboBox combo_result_jumps;
[Widget] Gtk.ComboBox combo_result_jumps_rj;
@@ -1943,8 +1944,6 @@ public partial class ChronoJumpWindow
* --------------------------------------------------------
*/
- string [] selectRunsIntervalString;
-
// ---------------- combo_select ----------------------
private void createComboSelectJumps(bool create)
@@ -1986,33 +1985,16 @@ public partial class ChronoJumpWindow
}
}
- private void createComboSelectRunsInterval(bool create) {
+ private void createComboSelectRunsInterval(bool create)
+ {
if(create)
- combo_select_runs_interval = ComboBox.NewText ();
-
- string [] runTypes = SqliteRunIntervalType.SelectRunIntervalTypes("", false); //without
allrunsname, not only name
- selectRunsIntervalString = new String [runTypes.Length];
- string [] runNamesToCombo = new String [runTypes.Length];
- int i =0;
- foreach(string runType in runTypes) {
- string [] j = runType.Split(new char[] {':'});
- string nameTranslated = Catalog.GetString(j[1]);
- selectRunsIntervalString[i] =
- j[0] + ":" + j[1] + ":" + nameTranslated + ":" + //uniqueID, name,
nameTranslated
- j[2] + ":" + j[3] + ":" + j[4] + ":" + //distance,
tracksLimited, fixedValue
- j[5] + ":" + j[6] + ":" + j[6]; //unlimited,
description, distancesString
- runNamesToCombo[i] = nameTranslated;
- i++;
- }
-
- UtilGtk.ComboUpdate(combo_select_runs_interval, runNamesToCombo, "");
- combo_select_runs_interval.Active = 0;
- combo_select_runs_interval.Changed += new EventHandler
(on_combo_select_runs_interval_changed);
-
- if(create) {
- hbox_combo_select_runs_interval.PackStart(combo_select_runs_interval, true, true, 0);
- hbox_combo_select_runs_interval.ShowAll();
- combo_select_runs_interval.Sensitive = false;
+ {
+ comboSelectRunsI = new CjComboSelectRunsI(combo_select_runs_interval,
hbox_combo_select_runs_interval);
+ combo_select_runs_interval = comboSelectRunsI.Combo;
+ combo_select_runs_interval.Changed += new EventHandler
(on_combo_select_runs_interval_changed);
+ } else {
+ comboSelectRunsI.Fill();
+ combo_select_runs_interval = comboSelectRunsI.Combo;
}
}
@@ -5936,7 +5918,7 @@ LogB.Debug("X");
SqliteRunType.SelectRunTypes(Constants.AllRunsName, true), "");
//without filter, only select name
new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added simple
run."));
} else {
- createComboSelectRunsInterval(false); //this will update also the
selectRunsIntervalString
+ createComboSelectRunsInterval(false);
UtilGtk.ComboUpdate(combo_result_runs_interval,
SqliteRunIntervalType.SelectRunIntervalTypes(Constants.AllRunsName,
true), ""); //without filter, only select name
@@ -6021,7 +6003,12 @@ LogB.Debug("X");
private void on_deleted_run_i_type (object o, EventArgs args)
{
- //TODO
+ string translatedName =
comboSelectRunsI.GetNameTranslated(runsIntervalMoreWin.SelectedEventName);
+ combo_select_runs_interval = comboSelectRunsI.DeleteValue(translatedName);
+
+ UtilGtk.ComboDelThisValue(combo_result_runs_interval, translatedName);
+ combo_result_runs_interval.Active = 0;
+
extra_window_runs_interval_initialize(new RunType("byLaps"));
}
diff --git a/src/gui/cjCombo.cs b/src/gui/cjCombo.cs
index c941d8b..08df52a 100644
--- a/src/gui/cjCombo.cs
+++ b/src/gui/cjCombo.cs
@@ -115,6 +115,8 @@ public class CjCombo
}
}
+//------------ jumps -------------
+
public class CjComboSelectJumps : CjCombo
{
public CjComboSelectJumps(Gtk.ComboBox combo_select_jumps, Gtk.HBox hbox_combo_select_jumps)
@@ -151,6 +153,8 @@ public class CjComboSelectJumpsRj : CjCombo
}
}
+//------------ runs -------------
+
public class CjComboSelectRuns : CjCombo
{
public CjComboSelectRuns(Gtk.ComboBox combo_select_runs, Gtk.HBox hbox_combo_select_runs)
@@ -169,3 +173,20 @@ public class CjComboSelectRuns : CjCombo
}
}
+public class CjComboSelectRunsI : CjCombo
+{
+ public CjComboSelectRunsI(Gtk.ComboBox combo_select_runs_interval, Gtk.HBox
hbox_combo_select_runs_interval)
+ {
+ this.combo = combo_select_runs_interval;
+ this.hbox = hbox_combo_select_runs_interval;
+
+ create();
+ Fill();
+ package();
+ }
+
+ protected override void select()
+ {
+ l_types = (List<object>) SqliteRunIntervalType.SelectRunIntervalTypesNew("", false);
//without allrunsname, not only name
+ }
+}
diff --git a/src/gui/run.cs b/src/gui/run.cs
index b3cfe37..a82bd19 100644
--- a/src/gui/run.cs
+++ b/src/gui/run.cs
@@ -948,7 +948,7 @@ partial class ChronoJumpWindow
private void on_extra_window_runs_interval_test_changed(object o, EventArgs args)
{
- string runEnglishName = Util.FindOnArray(':',2,1,
UtilGtk.ComboGetActive(combo_select_runs_interval), selectRunsIntervalString);
+ string runEnglishName = comboSelectRunsI.GetSelectedNameEnglish();
currentRunIntervalType = createRunType(runEnglishName, false);
extra_window_runs_interval_initialize(currentRunIntervalType);
@@ -1058,11 +1058,10 @@ partial class ChronoJumpWindow
comboSelectRuns.MakeActive(runsMoreWin.SelectedEventName);
}
- private void on_more_runs_interval_update_test (object o, EventArgs args) {
+ private void on_more_runs_interval_update_test (object o, EventArgs args)
+ {
currentEventType = new RunType(runsIntervalMoreWin.SelectedEventName);
- string runTranslatedName = Util.FindOnArray(':',1,2, runsIntervalMoreWin.SelectedEventName,
selectRunsIntervalString);
-
- combo_select_runs_interval.Active = UtilGtk.ComboMakeActive(combo_select_runs_interval,
runTranslatedName);
+ comboSelectRunsI.MakeActive(runsIntervalMoreWin.SelectedEventName);
}
diff --git a/src/sqlite/runType.cs b/src/sqlite/runType.cs
index 614792f..e787246 100644
--- a/src/sqlite/runType.cs
+++ b/src/sqlite/runType.cs
@@ -510,6 +510,52 @@ class SqliteRunIntervalType : SqliteRunType
return myLast;
}
+ //use SelectRunITypes object. Since 1.6.3
+ public static List<object> SelectRunIntervalTypesNew(string allRunsName, bool onlyName)
+ {
+ Sqlite.Open();
+ dbcmd.CommandText = "SELECT * " +
+ " FROM " + Constants.RunIntervalTypeTable +
+ " ORDER BY uniqueID";
+
+ LogB.SQL(dbcmd.CommandText.ToString());
+ dbcmd.ExecuteNonQuery();
+
+ SqliteDataReader reader;
+ reader = dbcmd.ExecuteReader();
+
+ List<object> types = new List<object>();
+
+ SelectRunITypes type;
+ if(allRunsName != "") {
+ type = new SelectRunITypes(allRunsName);
+ types.Add(type);
+ }
+
+ while(reader.Read()) {
+ if(onlyName) {
+ type = new SelectRunITypes(reader[1].ToString());
+ } else {
+ type = new SelectRunITypes(
+ Convert.ToInt32(reader[0]), //uniqueID
+ reader[1].ToString(), //nameEnglish
+
Convert.ToDouble(Util.ChangeDecimalSeparator(reader[2].ToString())), //distance
+ Util.IntToBool(Convert.ToInt32(reader[3].ToString())),
//tracksLimited
+ Convert.ToInt32(reader[4].ToString()),
//fixedValue
+ Util.IntToBool(Convert.ToInt32(reader[5].ToString())),
//unlimited
+ reader[6].ToString(),
//description
+ Util.ChangeDecimalSeparator(reader[7].ToString())
//distancesString
+ );
+ }
+ types.Add(type);
+ }
+
+ reader.Close();
+ Sqlite.Close();
+
+ return types;
+ }
+ //on newly cereated code use above method
public static string[] SelectRunIntervalTypes(string allRunsName, bool onlyName)
{
Sqlite.Open();
diff --git a/src/sqlite/usefulObjects.cs b/src/sqlite/usefulObjects.cs
index 6b45da5..22cf5ba 100644
--- a/src/sqlite/usefulObjects.cs
+++ b/src/sqlite/usefulObjects.cs
@@ -107,3 +107,30 @@ public class SelectRunTypes : SelectTypes
}
}
+public class SelectRunITypes : SelectRunTypes
+{
+ public bool TracksLimited;
+ public int FixedValue;
+ public bool Unlimited;
+ public string DistancesString;
+
+ public SelectRunITypes(string nameEnglish)
+ {
+ this.NameEnglish = nameEnglish;
+ }
+
+ public SelectRunITypes(int id, string nameEnglish, double distance,
+ bool tracksLimited, int fixedValue, bool unlimited,
+ string description, string distancesString)
+ {
+ this.Id = id;
+ this.NameEnglish = nameEnglish;
+ this.NameTranslated = Catalog.GetString(nameEnglish);
+ this.Distance = distance;
+ this.TracksLimited = tracksLimited;
+ this.FixedValue = fixedValue;
+ this.Unlimited = unlimited;
+ this.Description = description;
+ this.DistancesString = distancesString;
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]