[chronojump] sprint gui now adds after test, and better management of distances
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] sprint gui now adds after test, and better management of distances
- Date: Mon, 27 Mar 2017 15:32:59 +0000 (UTC)
commit 5f105a676452cd49b1f9fef133a2f78b27e0283d
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Mar 27 17:32:19 2017 +0200
sprint gui now adds after test, and better management of distances
src/gui/chronojump.cs | 3 +
src/gui/sprint.cs | 123 ++++++++++++++++++++++++++++++++----------------
2 files changed, 85 insertions(+), 41 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 8f5bd26..2aef21e 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2825,6 +2825,7 @@ public partial class ChronoJumpWindow
notebooks_change(3);
on_extra_window_runs_interval_test_changed(new object(), new EventArgs());
hbox_results_legend.Visible = false;
+ createTreeView_runs_interval_sprint (treeview_runs_interval_sprint);
notebook_capture_analyze.GetNthPage(3).Show(); //show sprint page
}
notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on runs
@@ -4280,6 +4281,8 @@ public partial class ChronoJumpWindow
event_execute_LabelTimeValue = currentRunInterval.TimeTotal;
//possible deletion of last run can make the runs on event window be false
event_execute_LabelEventValue = currentRunInterval.Tracks;
+
+ addTreeView_runs_interval_sprint (currentRunInterval, currentRunIntervalType);
}
else if( currentEventExecute.ChronopicDisconnected )
chronopicDisconnectedWhileExecuting();
diff --git a/src/gui/sprint.cs b/src/gui/sprint.cs
index 2d75182..e6a90ab 100644
--- a/src/gui/sprint.cs
+++ b/src/gui/sprint.cs
@@ -33,6 +33,7 @@ public partial class ChronoJumpWindow
[Widget] Gtk.Image image_sprint;
static Sprint sprint;
+ TreeStore storeSprint;
private void createTreeView_runs_interval_sprint (Gtk.TreeView tv)
{
@@ -48,10 +49,10 @@ public partial class ChronoJumpWindow
tv.AppendColumn ("Split times", new CellRendererText(), "text", count++);
tv.AppendColumn ("Total time", new CellRendererText(), "text", count++);
- TreeStore store = new TreeStore(
+ storeSprint = new TreeStore(
typeof (string), typeof (string), typeof (string),
typeof (string), typeof (string));
- tv.Model = store;
+ tv.Model = storeSprint;
if (currentSession == null || currentPerson == null)
return;
@@ -69,48 +70,17 @@ public partial class ChronoJumpWindow
string [] lineSplit = line.Split(new char[] {':'});
//get intervalTimes
- string intervalTimes = lineSplit[8];
- string [] intervalTimesSplit = intervalTimes.Split(new char[] {'='});
-
- //get positions
- string positions = "";
- string sep = "";
- if(lineSplit[7] != "-1") //not variable distances
- {
- double distanceIntervalD = Convert.ToDouble(lineSplit[7]);
- double distanceAccumulated = distanceIntervalD;
- for(int i=0; i < intervalTimesSplit.Length; i ++)
- {
- positions += sep + Util.TrimDecimals(distanceAccumulated,
preferences.digitsNumber);
- sep = ";";
- distanceAccumulated += distanceIntervalD;
- }
- } else { //variable distances
-
- //discard RSA
- if(lineSplit[4].Contains("R"))
- continue;
-
- positions = runIntervalTypeDistances(lineSplit[4], runITypes);
- }
+ string intervalTimesString = lineSplit[8];
+ string positions = getSprintPositions(
+ Convert.ToDouble(lineSplit[7]), //distanceInterval. == -1 means
variable distances
+ intervalTimesString,
+ runIntervalTypeDistances(lineSplit[4], runITypes)
//distancesString
+ );
if(positions == "")
continue;
- //format positions
- positions = Util.ChangeChars(positions, "-", ";");
-
- //manage accumulated time
- double timeAccumulated = 0;
- string splitTimes = "";
- sep = "";
- foreach(string time in intervalTimesSplit)
- {
- double timeD = Convert.ToDouble(time);
- timeAccumulated += timeD;
- splitTimes += sep + Util.TrimDecimals(timeAccumulated,
preferences.digitsNumber);
- sep = ";";
- }
+ string splitTimes = getSplitTimes(intervalTimesString);
string [] lineParams = {
lineSplit[4],
@@ -119,10 +89,81 @@ public partial class ChronoJumpWindow
splitTimes,
Util.TrimDecimals(lineSplit[6], preferences.digitsNumber)
};
- store.AppendValues (lineParams);
+ storeSprint.AppendValues (lineParams);
+ }
+ }
+
+ public void addTreeView_runs_interval_sprint (RunInterval runI, RunType runIType)
+ {
+ if(storeSprint == null)
+ {
+ createTreeView_runs_interval_sprint (treeview_runs_interval_sprint);
+ return;
+ }
+
+ string positions = getSprintPositions(
+ runI.DistanceInterval, //distanceInterval. == -1 means variable
distances
+ runI.IntervalTimesString,
+ runIType.DistancesString //distancesString
+ );
+ if(positions == "")
+ return;
+
+ TreeIter iter = new TreeIter();
+ bool iterOk = storeSprint.GetIterFirst(out iter);
+ if(iterOk) {
+ iter = storeSprint.AppendValues (
+ runI.Type,
+ runI.UniqueID.ToString(),
+ positions,
+ getSplitTimes(runI.IntervalTimesString),
+ Util.TrimDecimals(runI.TimeTotal, preferences.digitsNumber)
+ );
+
+ //scroll treeview if needed
+ TreePath path = storeSprint.GetPath (iter);
+ treeview_runs_interval_sprint.ScrollToCell (path, null, true, 0, 0);
}
}
+ private string getSprintPositions(double distanceInterval, string intervalTimesString, string
distancesString)
+ {
+ string positions = "";
+ string [] intervalTimesSplit = intervalTimesString.Split(new char[] {'='});
+ if(! distancesString.Contains("R") ) //discard RSA
+ {
+ string sep = "";
+ for(int i=0; i < intervalTimesSplit.Length; i ++)
+ {
+ positions += sep + Util.GetRunITotalDistance(distanceInterval,
distancesString, i+1);
+ sep = ";";
+ }
+
+ //format positions
+ positions = Util.ChangeChars(positions, "-", ";");
+ }
+ return positions;
+ }
+
+ private string getSplitTimes(string intervalTimesString)
+ {
+ string [] intervalTimesSplit = intervalTimesString.Split(new char[] {'='});
+
+ //manage accumulated time
+ double timeAccumulated = 0;
+ string splitTimes = "";
+ string sep = "";
+ foreach(string time in intervalTimesSplit)
+ {
+ double timeD = Convert.ToDouble(time);
+ timeAccumulated += timeD;
+ splitTimes += sep + Util.TrimDecimals(timeAccumulated, preferences.digitsNumber);
+ sep = ";";
+ }
+
+ return splitTimes;
+ }
+
private string runIntervalTypeDistances(string runTypeEnglishName, List<object> runITypes)
{
foreach(SelectRunITypes type in runITypes)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]