[chronojump] Report add/edit comment to stat. done!



commit f7214da983cb9ec203083c267d86c2e05513b2de
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Sep 4 16:10:15 2009 +0200

    Report add/edit comment to stat. done!

 glade/chronojump.glade   |   40 ++++++++++++++++++++++++++++++++++-
 src/constants.cs         |    4 +++
 src/gui/chronojump.cs    |    2 +-
 src/gui/genericWindow.cs |   47 +++++++++++++++++++++++++++---------------
 src/gui/person.cs        |    2 +-
 src/gui/report.cs        |   51 +++++++++++++++++++++++++++++++++++++++++----
 src/gui/session.cs       |    2 +-
 src/report.cs            |    1 +
 src/statType.cs          |   18 ----------------
 src/util.cs              |    7 ++++++
 10 files changed, 129 insertions(+), 45 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 043182a..b9b43c4 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -26418,7 +26418,7 @@ comments</property>
 	  <property name="spacing">4</property>
 
 	  <child>
-	    <widget class="GtkEntry" id="entry_value">
+	    <widget class="GtkEntry" id="entry">
 	      <property name="visible">True</property>
 	      <property name="can_focus">True</property>
 	      <property name="editable">True</property>
@@ -26437,7 +26437,7 @@ comments</property>
 	  </child>
 
 	  <child>
-	    <widget class="GtkSpinButton" id="spinbutton_value">
+	    <widget class="GtkSpinButton" id="spinbutton">
 	      <property name="visible">True</property>
 	      <property name="can_focus">True</property>
 	      <property name="climb_rate">0</property>
@@ -26454,6 +26454,42 @@ comments</property>
 	      <property name="fill">False</property>
 	    </packing>
 	  </child>
+
+	  <child>
+	    <widget class="GtkScrolledWindow" id="scrolled_window">
+	      <property name="visible">True</property>
+	      <property name="can_focus">True</property>
+	      <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
+	      <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+	      <property name="shadow_type">GTK_SHADOW_IN</property>
+	      <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+	      <child>
+		<widget class="GtkTextView" id="textview">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="overwrite">False</property>
+		  <property name="accepts_tab">True</property>
+		  <property name="justification">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap_mode">GTK_WRAP_NONE</property>
+		  <property name="cursor_visible">True</property>
+		  <property name="pixels_above_lines">0</property>
+		  <property name="pixels_below_lines">0</property>
+		  <property name="pixels_inside_wrap">0</property>
+		  <property name="left_margin">0</property>
+		  <property name="right_margin">0</property>
+		  <property name="indent">0</property>
+		  <property name="text" translatable="yes"></property>
+		</widget>
+	      </child>
+	    </widget>
+	    <packing>
+	      <property name="padding">0</property>
+	      <property name="expand">False</property>
+	      <property name="fill">False</property>
+	    </packing>
+	  </child>
 	</widget>
 	<packing>
 	  <property name="padding">0</property>
diff --git a/src/constants.cs b/src/constants.cs
index 144ad9c..0444200 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -431,6 +431,10 @@ public class Constants
 	//public static string HigherThanCode = "> ";
 	//public static string LowerOrEqualThanCode = "<=";
 	public static string HigherOrEqualThanCode = ">=";
+
+	public enum GenericWindowShow {
+		ENTRY, SPIN, TEXTVIEW
+	}
 	
 	public const string PrefVersionAvailable = "versionAvailable";
 
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 9b7c86a..c36f484 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2192,7 +2192,7 @@ public class ChronoJumpWindow
 
 	//show spinbutton window asking for how many people to create	
 	private void on_person_add_multiple_activate (object o, EventArgs args) {
-		genericWin = GenericWindow.Show(Catalog.GetString("Select number of persons to add"), false, true);
+		genericWin = GenericWindow.Show(Catalog.GetString("Select number of persons to add"), Constants.GenericWindowShow.SPIN);
 		genericWin.SetSpinRange(1.0, 40.0);
 		genericWin.Button_accept.Clicked += new EventHandler(on_person_add_multiple_prepared);
 	}
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index e13dca8..2e00399 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -31,8 +31,10 @@ public class GenericWindow
 	[Widget] Gtk.Window generic_window;
 	[Widget] Gtk.Label label_header;
 	[Widget] Gtk.Label label_generic_name;
-	[Widget] Gtk.Entry entry_value;
-	[Widget] Gtk.SpinButton spinbutton_value;
+	[Widget] Gtk.Entry entry;
+	[Widget] Gtk.SpinButton spinbutton;
+	[Widget] Gtk.ScrolledWindow scrolled_window;
+	[Widget] Gtk.TextView textview;
 	[Widget] Gtk.Button button_accept;
 
 	static GenericWindow GenericWindowBox;
@@ -47,12 +49,12 @@ public class GenericWindow
 		UtilGtk.IconWindow(generic_window);
 	}
 
-	static public GenericWindow Show (string textHeader, bool showEntry, bool showSpin)
+	static public GenericWindow Show (string textHeader, Constants.GenericWindowShow stuff)
 	{
 		if (GenericWindowBox == null) {
 			GenericWindowBox = new GenericWindow();
 		}
-		GenericWindowBox.showHideWidgets(showEntry, showSpin);
+		GenericWindowBox.showHideWidgets(stuff);
 		GenericWindowBox.label_header.Text = textHeader;
 
 		GenericWindowBox.generic_window.Show ();
@@ -60,20 +62,27 @@ public class GenericWindow
 		return GenericWindowBox;
 	}
 	
-	void showHideWidgets(bool showEntry, bool showSpin) {
-		if(showEntry)
-			entry_value.Show();
-		else
-			entry_value.Hide();
-		
-		if(showSpin)
-			spinbutton_value.Show();
-		else
-			spinbutton_value.Hide();
+	void showHideWidgets(Constants.GenericWindowShow stuff) {
+		entry.Hide();
+		spinbutton.Hide();
+		scrolled_window.Hide();
+
+		if(stuff == Constants.GenericWindowShow.ENTRY)
+			entry.Show();
+		else if(stuff == Constants.GenericWindowShow.SPIN)
+			spinbutton.Show();
+		else //if(stuff == Constants.GenericWindowShow.TEXTVIEW)
+			scrolled_window.Show();
 	}
 	
 	public void SetSpinRange(double min, double max) {
-		spinbutton_value.SetRange(min, max);
+		spinbutton.SetRange(min, max);
+	}
+	
+	public void SetTextview(string str) {
+		TextBuffer tb = new TextBuffer (new TextTagTable());
+		tb.Text = str;
+		textview.Buffer = tb;
 	}
 
 
@@ -101,11 +110,15 @@ public class GenericWindow
 	}
 
 	public string EntrySelected {
-		get { return entry_value.Text.ToString(); }
+		get { return entry.Text.ToString(); }
 	}
 
 	public int SpinSelected {
-		get { return (int) spinbutton_value.Value; }
+		get { return (int) spinbutton.Value; }
+	}
+	
+	public string TextviewSelected {
+		get { return Util.RemoveTab(textview.Buffer.Text); }
 	}
 	
 
diff --git a/src/gui/person.cs b/src/gui/person.cs
index f1eba57..5f11c55 100644
--- a/src/gui/person.cs
+++ b/src/gui/person.cs
@@ -1310,7 +1310,7 @@ public class PersonAddModifyWindow
 	void on_button_sport_add_clicked (object o, EventArgs args)
 	{
 		Log.WriteLine("sport add clicked");
-		genericWin = GenericWindow.Show(Catalog.GetString("Add new sport to database"), true, false);
+		genericWin = GenericWindow.Show(Catalog.GetString("Add new sport to database"), Constants.GenericWindowShow.ENTRY);
 		genericWin.Button_accept.Clicked += new EventHandler(on_sport_add_accepted);
 	}
 
diff --git a/src/gui/report.cs b/src/gui/report.cs
index 7307015..48b2668 100644
--- a/src/gui/report.cs
+++ b/src/gui/report.cs
@@ -49,6 +49,8 @@ public class ReportWindow {
 	[Widget] Gtk.Image image_report_win_graph;
 	[Widget] Gtk.Image image_report_win_report;
 	
+	GenericWindow genericWin;
+	
 	static ReportWindow ReportWindowBox;
 
 	Gtk.Window parent;
@@ -75,7 +77,8 @@ public class ReportWindow {
 		//treeview
 		createTreeView(treeview1);
 		store = new TreeStore( typeof (string), typeof (string), typeof (string), 
-				typeof (string), typeof (string), typeof (string), typeof (string), typeof (string)
+				typeof (string), typeof (string), typeof (string), typeof (string), 
+				typeof (string), typeof (string)
 				);
 		treeview1.Model = store;
 		
@@ -134,6 +137,7 @@ public class ReportWindow {
 		tv.AppendColumn ( Catalog.GetString("Show sex"), new CellRendererText(), "text", count++);
 		tv.AppendColumn ( Catalog.GetString("Checked rows"), new CellRendererText(), "text", count++);
 		tv.AppendColumn ( Catalog.GetString("Graph Options"), new CellRendererText(), "text", count++);
+		tv.AppendColumn ( Catalog.GetString("Comment"), new CellRendererText(), "text", count++);
 	}
 
 	void loadCheckBoxes () 
@@ -166,7 +170,8 @@ public class ReportWindow {
 					myStringFull[4],	//showJumps
 					myStringFull[5],	//showSex
 					myStringFull[6],	//markedRows
-					myStringFull[7]		//graphROptions
+					myStringFull[7],	//graphROptions
+					myStringFull[8]		//comment
 					);
 		}
 
@@ -199,7 +204,8 @@ public class ReportWindow {
 				showJumps, 
 				showSex,
 				markedRowsAsAString,
-				gro.ToString()
+				gro.ToString(),
+				""		//comment
 				);
 		
 		//show report window if it's not shown
@@ -326,7 +332,41 @@ public class ReportWindow {
 	}
 	
 	private void on_button_add_comment_clicked (object o, EventArgs args) {
-		new DialogMessage(Constants.MessageTypes.INFO, "not implemented yet");
+		//new DialogMessage(Constants.MessageTypes.INFO, "not implemented yet");
+
+		//see if there's any comment
+		string comment = "";
+		if(selected)
+		{
+			TreeModel model;
+			TreeIter iter1; 
+
+			if (treeview1.Selection.GetSelected (out model, out iter1)) {
+				string str=getRow(iter1);
+				string [] statRow = str.ToString().Split(new char[] {'\t'});
+				comment = statRow[8];
+			}
+			
+			genericWin = GenericWindow.Show(Catalog.GetString("Comment this statistic"), Constants.GenericWindowShow.TEXTVIEW);
+			genericWin.SetTextview(comment);
+			genericWin.Button_accept.Clicked += new EventHandler(on_comment_add_accepted);
+		}
+	}
+	
+	private void on_comment_add_accepted (object o, EventArgs args) {
+		genericWin.Button_accept.Clicked -= new EventHandler(on_comment_add_accepted);
+		string comment = genericWin.TextviewSelected;
+		
+		if(selected)
+		{
+			TreeModel model;
+			TreeIter iter1; 
+
+			if (treeview1.Selection.GetSelected (out model, out iter1)) {
+				string str=getRow(iter1);
+				store.SetValue (iter1, 8, comment);
+			}
+		}
 	}
 
 	private void on_button_delete_clicked (object o, EventArgs args) {
@@ -406,7 +446,8 @@ public class ReportWindow {
 			(string) treeview1.Model.GetValue (myIter, 4) + "\t" +	//showJumps
 			(string) treeview1.Model.GetValue (myIter, 5) + "\t" +  //showSex
 			(string) treeview1.Model.GetValue (myIter, 6) + "\t" +	//markedRowsString
-			(string) treeview1.Model.GetValue (myIter, 7) 		//GraphROptions
+			(string) treeview1.Model.GetValue (myIter, 7) + "\t" + 	//GraphROptions
+			(string) treeview1.Model.GetValue (myIter, 8) 		//Comment
 			;
 	}
 	
diff --git a/src/gui/session.cs b/src/gui/session.cs
index 5a440ed..8bfc8f8 100644
--- a/src/gui/session.cs
+++ b/src/gui/session.cs
@@ -524,7 +524,7 @@ public class SessionAddEditWindow {
 	void on_button_sport_add_clicked (object o, EventArgs args)
 	{
 		Log.WriteLine("sport add clicked");
-		genericWin = GenericWindow.Show(Catalog.GetString("Add new sport to database"), true, false);
+		genericWin = GenericWindow.Show(Catalog.GetString("Add new sport to database"), Constants.GenericWindowShow.ENTRY);
 		genericWin.Button_accept.Clicked += new EventHandler(on_sport_add_accepted);
 	}
 
diff --git a/src/report.cs b/src/report.cs
index 01ffadc..52fa59a 100644
--- a/src/report.cs
+++ b/src/report.cs
@@ -435,6 +435,7 @@ public class Report : ExportSession
 			//because myStatType of a graph doesn't know the numContinuous value 
 			//needed for enunciate in rj evolution statistic
 			writer.WriteLine(myEnunciate);
+			writer.WriteLine("<tr><td>" + strFull[8] + "</td></tr>"); //comment
 			writer.WriteLine("</table>");
 		}
 	}
diff --git a/src/statType.cs b/src/statType.cs
index 105e3f5..c0e7ec9 100644
--- a/src/statType.cs
+++ b/src/statType.cs
@@ -38,10 +38,6 @@ public class StatTypeStruct
 	public bool WeightStatsPercent; 
 	
 	public ArrayList MarkedRows;
-	
-	//public string GraphType;
-	//public string GraphPalette;
-	//public bool GraphTransposed;
 	public GraphROptions GRO;
 	
 	public bool ToReport;
@@ -49,9 +45,7 @@ public class StatTypeStruct
 	public StatTypeStruct (string statisticApplyTo, 
 			ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active, 
 			int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent, 
-			//int statsJumpsType, int limit, bool heightPreferred, 
 			ArrayList markedRows, 
-			//string graphType, string graphPalette, bool graphTransposed,
 			GraphROptions gRO,
 			bool toReport)
 	{
@@ -87,9 +81,6 @@ public class StatType {
 	ArrayList markedRows;
 	ArrayList personsWithData;
 
-	//string graphType;
-	//string graphPalette;
-	//bool graphTransposed;
 	GraphROptions gRO;
 	
 	bool graph;
@@ -123,10 +114,8 @@ public class StatType {
 	public StatType (string statisticType, string statisticSubType, string statisticApplyTo, Gtk.TreeView treeview_stats,
 			ArrayList sendSelectedSessions, int prefsDigitsNumber, bool sex_active, 
 			int statsJumpsType, int limit, bool heightPreferred, bool weightStatsPercent,
-			//int statsJumpsType, int limit, bool heightPreferred, 
 			ArrayList markedRows,  
 			int rj_evolution_mark_consecutives, 
-			//string graphType, string graphPalette, bool graphTransposed,
 			GraphROptions gRO,
 			bool graph, bool toReport)
 	{
@@ -147,9 +136,6 @@ public class StatType {
 		
 		this.rj_evolution_mark_consecutives = rj_evolution_mark_consecutives;
 		
-		//this.graphType = graphType;
-		//this.graphPalette = graphPalette;
-		//this.graphTransposed = graphTransposed;
 		this.gRO = gRO;
 		
 		this.graph = graph;
@@ -159,9 +145,7 @@ public class StatType {
 				statisticApplyTo,
 				sendSelectedSessions, prefsDigitsNumber, sex_active, 
 				statsJumpsType, limit, heightPreferred, weightStatsPercent, 
-				//statsJumpsType, limit, heightPreferred,  
 				markedRows, 
-				//graphType, graphPalette, graphTransposed,
 				gRO,
 				toReport);
 
@@ -225,9 +209,7 @@ public class StatType {
 				statisticApplyTo,
 				sendSelectedSessions, prefsDigitsNumber, sex_active, 
 				statsJumpsType, limit, heightPreferred, weightStatsPercent, 
-				//statsJumpsType, limit, heightPreferred, 
 				markedRows, 
-				//graphType, graphPalette, graphTransposed,
 				gRO,
 				toReport);
 
diff --git a/src/util.cs b/src/util.cs
index 9d4afa5..6d27907 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -283,6 +283,13 @@ public class Util
 		return myStringBuilder.ToString();
 	}
 	
+	public static string RemoveTab(string myString) 
+	{
+		StringBuilder myStringBuilder = new StringBuilder(myString);
+		myStringBuilder.Replace("\t", " ");
+		return myStringBuilder.ToString();
+	}
+
 	public static string RemoveNewLine(string myString) 
 	{
 		StringBuilder myStringBuilder = new StringBuilder(myString);



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