[longomatch/redesign2: 140/140] WIP



commit d5dc7acea49eb0d97559e300358028090abaa072
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue May 24 23:52:34 2011 +0200

    WIP

 LongoMatch/DB/DataBase.cs                          |    4 +-
 LongoMatch/Gui/Component/PlayersTaggerWidget.cs    |   86 +++++++++++
 LongoMatch/Gui/Component/StringTaggerWidget.cs     |   80 +++++++++++
 LongoMatch/Gui/Component/SubCategoryTagsEditor.cs  |   30 ++++
 LongoMatch/Gui/Component/TaggerWidget.cs           |   92 ++-----------
 LongoMatch/Gui/Component/TagsTreeWidget.cs         |   19 ++-
 LongoMatch/Gui/Dialog/SubCategoryEditor.cs         |  108 ++++++++++++++
 LongoMatch/IO/CSVExport.cs                         |    4 +-
 LongoMatch/LongoMatch.mdp                          |    4 +
 LongoMatch/Store/Play.cs                           |   36 ++++-
 LongoMatch/Store/Project.cs                        |   37 +++--
 LongoMatch/Store/Tag.cs                            |   45 ++-----
 ...LongoMatch.Gui.Component.PlayersTaggerWidget.cs |   19 +++
 .../LongoMatch.Gui.Component.StringTaggerWidget.cs |   46 ++++++
 .../LongoMatch.Gui.Component.TaggerWidget.cs       |   75 +---------
 LongoMatch/gtk-gui/gui.stetic                      |  151 ++++++++++++-------
 16 files changed, 566 insertions(+), 270 deletions(-)
---
diff --git a/LongoMatch/DB/DataBase.cs b/LongoMatch/DB/DataBase.cs
index bdab111..eb544c5 100644
--- a/LongoMatch/DB/DataBase.cs
+++ b/LongoMatch/DB/DataBase.cs
@@ -355,7 +355,7 @@ namespace LongoMatch.DB
 			Db4oFactory.Configure().ObjectClass(typeof(Team)).CascadeOnDelete(true);
 			Db4oFactory.Configure().ObjectClass(typeof(HotKey)).CascadeOnDelete(true);
 			Db4oFactory.Configure().ObjectClass(typeof(Player)).CascadeOnDelete(true);
-			Db4oFactory.Configure().ObjectClass(typeof(Tag)).CascadeOnDelete(true);
+			Db4oFactory.Configure().ObjectClass(typeof(StringTag)).CascadeOnDelete(true);
 			Db4oFactory.Configure().ObjectClass(typeof(TeamTemplate)).CascadeOnDelete(true);
 			Db4oFactory.Configure().ObjectClass(typeof(Drawing)).CascadeOnDelete(true);
 		}
@@ -371,7 +371,7 @@ namespace LongoMatch.DB
 			Db4oFactory.Configure().ObjectClass(typeof(HotKey)).CascadeOnUpdate(true);
 			Db4oFactory.Configure().ObjectClass(typeof(Player)).CascadeOnUpdate(true);
 			Db4oFactory.Configure().ObjectClass(typeof(TeamTemplate)).CascadeOnUpdate(true);
-			Db4oFactory.Configure().ObjectClass(typeof(Tag)).CascadeOnDelete(true);
+			Db4oFactory.Configure().ObjectClass(typeof(StringTag)).CascadeOnDelete(true);
 			Db4oFactory.Configure().ObjectClass(typeof(Drawing)).CascadeOnUpdate(true);
 		}
 
diff --git a/LongoMatch/Gui/Component/PlayersTaggerWidget.cs b/LongoMatch/Gui/Component/PlayersTaggerWidget.cs
new file mode 100644
index 0000000..91f2c0b
--- /dev/null
+++ b/LongoMatch/Gui/Component/PlayersTaggerWidget.cs
@@ -0,0 +1,86 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using System.Collections.Generic;
+using Gtk;
+
+using LongoMatch.Store;
+using LongoMatch.Store.Templates;
+
+namespace LongoMatch.Gui.Component
+{
+	[System.ComponentModel.ToolboxItem(true)]
+	public partial class PlayersTaggerWidget : Gtk.Bin
+	{
+		TeamTemplate template;
+		Dictionary<CheckButton, Player> checkButtonsDict;
+
+		public PlayersTaggerWidget ()
+		{
+			this.Build ();
+			checkButtonsDict = new Dictionary<CheckButton, Player>();
+		}
+
+		public void SetPlayersInfo(TeamTemplate template) {
+			CheckButton button;
+			List<Player> playersList;
+			int i=0;
+
+			if(this.template != null)
+				return;
+
+			this.template = template;
+			playersList = template.PlayingPlayersList;
+
+			table1.NColumns =(uint)(playersList.Count/10);
+			table1.NRows =(uint) 10;
+
+			foreach(Player player in playersList) {
+				button = new CheckButton();
+				button.Label = player.Number + "-" + player.Name;
+				button.Name = i.ToString();
+				button.Show();
+
+				uint row_top =(uint)(i%table1.NRows);
+				uint row_bottom = (uint) row_top+1 ;
+				uint col_left = (uint) i/table1.NRows;
+				uint col_right = (uint) col_left+1 ;
+
+				table1.Attach(button,col_left,col_right,row_top,row_bottom);
+				checkButtonsDict.Add(button, player);
+				i++;
+			}
+		}
+
+		public List<Player> PlayersChecked {
+			set {
+				foreach(var pair in checkButtonsDict)
+					pair.Key.Active = value.Contains(pair.Value);
+			}
+			get {
+				List<Player> playersList = new List<Player>();
+				foreach(var pair in checkButtonsDict) {
+					if(pair.Key.Active)
+						playersList.Add(pair.Value);
+				}
+				return playersList;
+			}
+		}
+	}
+}
+
diff --git a/LongoMatch/Gui/Component/StringTaggerWidget.cs b/LongoMatch/Gui/Component/StringTaggerWidget.cs
new file mode 100644
index 0000000..09afa91
--- /dev/null
+++ b/LongoMatch/Gui/Component/StringTaggerWidget.cs
@@ -0,0 +1,80 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using System.Collections.Generic;
+using Gtk;
+
+using LongoMatch.Store;
+
+namespace LongoMatch.Gui.Component
+{
+	[System.ComponentModel.ToolboxItem(true)]
+	public partial class StringTaggerWidget : Gtk.Bin
+	{
+		private Dictionary<string, Widget> dict;
+		private StringTag tag;
+		
+		public StringTaggerWidget ()
+		{
+			this.Build ();
+			dict = new Dictionary<string, Widget>();
+		}
+		
+		public TagSubCategory SubCategory {
+			set {
+				Title = SubCategory.Name;
+				foreach (string tag in value)
+					AddWidget(tag);
+			}
+		}
+		
+		public StringTag Tag {
+			set{
+				tag = value;
+				foreach (string val in tag){
+					if (dict.ContainsKey[val])
+						dict[val].Active = true; 
+				}
+			}
+			get {
+				return tag;
+			}
+		}
+		
+		private void AddTagWidget (string name){
+			var button = new CheckButton(name);
+			button.Toggled += delegate(object sender, EventArgs e) {
+				if (button.Active)
+					tag.Add(name);
+				else
+					tag.Remove(name);
+			};
+			dict.Add(name, button);
+			buttonsbox.PackStart(button, true, false, 0);
+			button.ShowAll();
+		} 
+		
+		private string Title {
+			set {
+				frame.Label = "<b>" + value + "</b>";
+			}
+		}
+		
+	}
+}
+
diff --git a/LongoMatch/Gui/Component/SubCategoryTagsEditor.cs b/LongoMatch/Gui/Component/SubCategoryTagsEditor.cs
new file mode 100644
index 0000000..6108a6e
--- /dev/null
+++ b/LongoMatch/Gui/Component/SubCategoryTagsEditor.cs
@@ -0,0 +1,30 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+namespace LongoMatch.Gui.Component
+{
+	[System.ComponentModel.ToolboxItem(true)]
+	public partial class SubCategoryTagsEditor : Gtk.Bin
+	{
+		public SubCategoryTagsEditor ()
+		{
+			this.Build ();
+		}
+	}
+}
+
diff --git a/LongoMatch/Gui/Component/TaggerWidget.cs b/LongoMatch/Gui/Component/TaggerWidget.cs
index 86c15b3..9c62446 100644
--- a/LongoMatch/Gui/Component/TaggerWidget.cs
+++ b/LongoMatch/Gui/Component/TaggerWidget.cs
@@ -29,91 +29,21 @@ namespace LongoMatch.Gui.Component
 	[System.ComponentModel.ToolboxItem(true)]
 	public partial class TaggerWidget : Gtk.Bin
 	{
-		private Dictionary<Tag, CheckButton> tagsDict;
-
 		public TaggerWidget()
 		{
 			this.Build();
-			tagsDict = new Dictionary<Tag, CheckButton>();
-			table1.NColumns = 5;
-		}
-
-
-		public List<Tag> Tags {
-			set {
-				CheckButton button = null;
-				foreach(Tag tag in value) {
-					if(tagsDict.TryGetValue(tag, out button))
-						button.Active = true;
-				}
-			}
-			get {
-				List<Tag> list = new List<Tag>();
-				foreach(KeyValuePair<Tag, CheckButton> pair in tagsDict) {
-					if(pair.Value.Active)
-						list.Add(pair.Key);
-				}
-				return list;
-			}
-		}
-
-		private void AddTag(string text, bool check) {
-			Tag tag = new Tag {
-				Value = text,
-			};
-			if(tagsDict.ContainsKey(tag))
-				return;
-			AddTagWidget(tag, check);
-		}
-
-		private void AddTagWidget(Tag tag, bool check) {
-			CheckButton button = new CheckButton(tag.Value.ToString());
-			button.Name = tag.Value.ToString();
-			AddElementToTable(button);
-			button.Active = check;
-			tagsDict.Add(tag, button);
-		}
-
-		private void AddElementToTable(CheckButton button) {
-			uint row_top,row_bottom,col_left,col_right;
-			int index = tagsDict.Count;
-
-			table1.NRows =(uint)(index/5 + 1);
-			row_top =(uint)(index/table1.NColumns);
-			row_bottom = (uint) row_top+1 ;
-			col_left = (uint) index%table1.NColumns;
-			col_right = (uint) col_left+1 ;
-
-			table1.Attach(button,col_left,col_right,row_top,row_bottom);
-			button.Show();
+			table1.NColumns = 1;
+			table1.NRows = 1;
 		}
-
-		protected virtual void OnTagbuttonClicked(object sender, System.EventArgs e)
-		{
-			Tag tag;
-			CheckButton button;
-
-			// Don't allow tags with void strings
-			if(entry1.Text == "")
-				return;
-			// Check if it's the first tag and show the tags table
-			if(tagsDict.Count == 0) {
-				scrolledwindow1.Visible = true;
-				label1.Visible = false;
-			}
-			tag = new Tag {
-				Value = entry1.Text,
-			};
-			if(tagsDict.TryGetValue(tag, out button))
-				button.Active = true;
-			else
-				AddTag(entry1.Text, true);
-			entry1.Text = "";
-		}
-
-		protected virtual void OnEntry1Activated(object sender, System.EventArgs e)
-		{
-			tagbutton.Click();
+		
+		public void AddSubCategory(TagSubCategory subcat, StringTag tag){
+			StringTaggerWidget tagger = new StringTaggerWidget();
+			tagger.SubCategory = subcat;
+			tagger.Tag = tag;
+			
+			table1.Attach(tagger,0, 1, table1.NRows, table1.NRows-1);
+			table1.NRows ++;
+			tagger.Show();
 		}
 	}
 }
\ No newline at end of file
diff --git a/LongoMatch/Gui/Component/TagsTreeWidget.cs b/LongoMatch/Gui/Component/TagsTreeWidget.cs
index 9fec3b4..fba92a6 100644
--- a/LongoMatch/Gui/Component/TagsTreeWidget.cs
+++ b/LongoMatch/Gui/Component/TagsTreeWidget.cs
@@ -33,6 +33,17 @@ namespace LongoMatch.Gui.Component
 		AND = 1
 	}
 
+	public class Tag:List<string> 
+	{
+		public string Value {
+			set {
+				
+			}
+			get {
+				return "";
+			}
+		}
+	}
 
 	[System.ComponentModel.Category("LongoMatch")]
 	[System.ComponentModel.ToolboxItem(true)]
@@ -135,8 +146,8 @@ namespace LongoMatch.Gui.Component
 
 		public void UpdateTagsList() {
 			(tagscombobox.Model as ListStore).Clear();
-			foreach(Tag tag in project.Tags)
-				tagscombobox.AppendText(tag.Value.ToString());
+			//foreach(Tag tag in project.Tags)
+			//	tagscombobox.AppendText(tag.Value.ToString());
 		}
 
 		private void AddFilterWidget(Tag tag) {
@@ -203,13 +214,13 @@ namespace LongoMatch.Gui.Component
 
 			if(filterType == FilterType.OR) {
 				foreach(Tag tag in filterTags) {
-					if(tNode.Tags.Contains(tag))
+				//	if(tNode.Tags.Contains(tag))
 						return true;
 				}
 				return false;
 			} else {
 				foreach(Tag tag in filterTags) {
-					if(! tNode.Tags.Contains(tag))
+					//if(! tNode.Tags.Contains(tag))
 						return false;
 				}
 				return true;
diff --git a/LongoMatch/Gui/Dialog/SubCategoryEditor.cs b/LongoMatch/Gui/Dialog/SubCategoryEditor.cs
new file mode 100644
index 0000000..63aa028
--- /dev/null
+++ b/LongoMatch/Gui/Dialog/SubCategoryEditor.cs
@@ -0,0 +1,108 @@
+// 
+//  Copyright (C) 2011 Andoni Morales Alastruey
+// 
+//  This program is free software; you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation; either version 2 of the License, or
+//  (at your option) any later version.
+// 
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//  GNU General Public License for more details.
+//  
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+// 
+using System;
+using Gtk;
+using Mono.Unix;
+using LongoMatch.Store;
+
+namespace LongoMatch.Gui.Dialog
+{
+	public partial class SubCategoryEditor : Gtk.Dialog
+	{
+		private TagSubCategory subcat;
+		
+		public SubCategoryEditor ()
+		{
+			this.Build ();
+		}
+		
+		public TagSubCategory SubCategory{
+			set {
+				ListStore store = new ListStore(typeof (string));
+				foreach (string tag in value.Options)
+					store.AppendValues(tag);
+				subcat = value;
+			}
+			get {
+				return subcat;
+			}
+		}
+		
+		protected virtual void OnDeletebuttonClicked (object sender, System.EventArgs e)
+		{
+			TreeIter iter;
+			string tag;
+			
+			if (!treeview1.Selection.GetSelected(out iter))
+				return;
+			tag = (string)treeview1.Model.GetValue(iter, 0);
+			SubCategory.Options.Remove(tag);
+			(treeview1.Model as ListStore).Remove(ref iter);
+		}		
+		
+		protected virtual void OnEditbuttonClicked (object sender, System.EventArgs e)
+		{
+			EntryDialog nameDialog;
+			string old_option, new_option;
+			TreeIter iter;
+			
+			if (!treeview1.Selection.GetSelected(out iter))
+				return;
+			
+			old_option = (string)treeview1.Model.GetValue(iter, 0);
+			
+			nameDialog = new EntryDialog();
+			nameDialog.ShowCount = false;
+			nameDialog.Text = old_option;
+			if (nameDialog.Run() == (int)ResponseType.Ok) {
+				new_option = nameDialog.Text;
+				if (new_option != old_option) {
+					SubCategory.Options.Remove(old_option);
+					SubCategory.Options.Add(new_option);
+					old_option = new_option;
+				}
+			}
+			nameDialog.Dispose();
+		}
+		
+		protected virtual void OnAddbuttonClicked (object sender, System.EventArgs e)
+		{
+			EntryDialog nameDialog = new EntryDialog();
+			nameDialog.ShowCount = false;
+			if (nameDialog.Run() == (int)ResponseType.Ok) {
+				SubCategory.Options.Add(nameDialog.Text);
+				(treeview1.Model as ListStore).AppendValues(nameDialog.Text);
+			}
+			nameDialog.Dispose();
+		}
+		
+		protected virtual void OnEntry1Changed (object sender, System.EventArgs e)
+		{
+			SubCategory.Name = nameentry.Text;
+		}
+		
+		protected virtual void OnTreeview1RowActivated (object o, Gtk.RowActivatedArgs args)
+		{
+		}
+		
+		protected virtual void OnTreeview1CursorChanged (object sender, System.EventArgs e)
+		{
+		}
+	}
+}
+
diff --git a/LongoMatch/IO/CSVExport.cs b/LongoMatch/IO/CSVExport.cs
index 42a57ea..7a4fa41 100644
--- a/LongoMatch/IO/CSVExport.cs
+++ b/LongoMatch/IO/CSVExport.cs
@@ -129,7 +129,7 @@ namespace LongoMatch.IO
 
 		#region Private Methods
 
-		private void WriteCatagoriesData(TextWriter tx, Dictionary<Tag, List<Play>> tagsDic) {
+		/***private void WriteCatagoriesData(TextWriter tx, Dictionary<Tag, List<Play>> tagsDic) {
 			// Write Tags table
 			tx.WriteLine(String.Format("{0};{1};{2};{3};{4}",
 			                           Catalog.GetString("Tag"),
@@ -178,7 +178,7 @@ namespace LongoMatch.IO
 			}
 			tx.WriteLine();
 			tx.WriteLine();
-		}
+		}***/
 		#endregion
 	}
 }
diff --git a/LongoMatch/LongoMatch.mdp b/LongoMatch/LongoMatch.mdp
index c40cb04..49b5bc5 100644
--- a/LongoMatch/LongoMatch.mdp
+++ b/LongoMatch/LongoMatch.mdp
@@ -191,6 +191,10 @@
     <File subtype="Directory" buildaction="Compile" name="Utils" />
     <File subtype="Code" buildaction="Compile" name="Gui/Dialog/SubCategoryTagsEditor.cs" />
     <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Dialog.SubCategoryTagsEditor.cs" />
+    <File subtype="Code" buildaction="Compile" name="Gui/Component/PlayersTaggerWidget.cs" />
+    <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.PlayersTaggerWidget.cs" />
+    <File subtype="Code" buildaction="Compile" name="Gui/Component/StringTaggerWidget.cs" />
+    <File subtype="Code" buildaction="Compile" name="gtk-gui/LongoMatch.Gui.Component.StringTaggerWidget.cs" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch/Store/Play.cs b/LongoMatch/Store/Play.cs
index 5e02666..35abe8f 100644
--- a/LongoMatch/Store/Play.cs
+++ b/LongoMatch/Store/Play.cs
@@ -39,7 +39,8 @@ namespace LongoMatch.Store
 		#region Constructors
 		public Play() {
 			Drawings = new DrawingsList();
-			Tags = new List<Tag>();
+			Tags = new List<StringTag>();
+			PlayerTags = new List<PlayerTag>();
 		}
 		#endregion
 
@@ -162,10 +163,21 @@ namespace LongoMatch.Store
 		//// <summary>
 		/// Play's tags
 		/// </summary>
-		public List<Tag> Tags {
+		public List<StringTag> Tags {
 			get;
 			set;
 		}
+		
+		public List<PlayerTag> PlayerTags {
+			get;
+			set;
+		}
+		
+		public List<TeamTag> Teams {
+			get;
+			set;
+		}
+		
 		#endregion
 
 		#region Public methods
@@ -181,14 +193,14 @@ namespace LongoMatch.Store
 		public bool HasFrame(int frame) {
 			return (frame>=StartFrame && frame<StopFrame);
 		}
-
+		
 		/// <summary>
 		/// Adds a new tag to the play
 		/// </summary>
 		/// <param name="tag">
 		/// A <see cref="Tag"/>: the tag to add
 		/// </param>
-		public void AddTag(Tag tag) {
+		public void AddTag(StringTag tag) {
 			if(!Tags.Contains(tag))
 				Tags.Add(tag);
 		}
@@ -199,7 +211,7 @@ namespace LongoMatch.Store
 		/// <param name="tag">
 		/// A <see cref="Tag"/>: the tag to remove
 		/// </param>
-		public void RemoveTag(Tag tag) {
+		public void RemoveTag(StringTag tag) {
 			if(Tags.Contains(tag))
 				Tags.Remove(tag);
 		}
@@ -216,12 +228,20 @@ namespace LongoMatch.Store
 		/// <returns>
 		/// A <see cref="System.Boolean"/>
 		/// </returns>
-		public bool HasTag(String name, object val) {
+		public bool HasTag(String subcategory, object val) {
 			return (from tag in Tags
-			        where(tag.Name == (string)name) && (tag.Value == val)
+			        where(tag.SubCategory == (string)subcategory) && (tag.Value == val)
 			        select tag).Count() > 0;
 		}
-
+		
+		public List<Player> Players {
+			get{
+				return (from tag in PlayerTags
+				        group tag by tag.Value into playersGroup
+				        select playersGroup.Key).ToList();
+			}
+		}
+		
 		public override string ToString()
 		{
 			String[] tags = new String[Tags.Count];
diff --git a/LongoMatch/Store/Project.cs b/LongoMatch/Store/Project.cs
index 8b46da3..c6d87f9 100644
--- a/LongoMatch/Store/Project.cs
+++ b/LongoMatch/Store/Project.cs
@@ -50,11 +50,15 @@ namespace LongoMatch.Store
 
 
 		private List<Play> playsList;
+		/* Helps maintaining a reverse index with player-> List<Plays> to build
+		 * the tree model in a faster wasy */
+		private Dictionary<Player, List<Play>> playersIndex;
 
 
 		#region Constructors
 		public Project() {
 			playsList = new List<Play>();
+			playersIndex = new Dictionary<Player, List<Play>>();
 			Categories = new Categories();
 			LocalTeamTemplate = new TeamTemplate();
 			VisitorTeamTemplate = new TeamTemplate();
@@ -189,13 +193,6 @@ namespace LongoMatch.Store
 			        select play).ToList();
 		}
 
-		public List<Tag> Tags {
-			get {
-				/* FIXME: Fix that when I have decide what to do with tags*/
-				return new List<Tag>();
-			}
-		}
-
 		/// <summary>
 		/// Returns a <see cref="Gtk.TreeStore"/> in which project categories are
 		/// root nodes and their respectives plays child nodes
@@ -281,17 +278,27 @@ namespace LongoMatch.Store
 			return dataFileListStore;
 		}
 
-		private TreeStore GetSubCategoryModel(PlayerSubCategory subcat) {
-			TreeStore dataFileListStore = new TreeStore(typeof(object));
+		private TreeStore GetPlayersModel(Team team) {
+			Dictionary<Player, TreeIter> dict = new Dictionary<Player, TreeIter>();
+			TreeStore store = new TreeStore(typeof(object));
 			TeamTemplate template;
 
-			foreach(Team team in subcat) {
-				if(team == Team.NONE)
-					continue;
-				template = team == Team.LOCAL?LocalTeamTemplate:VisitorTeamTemplate;
-				FillList(template, subcat.Name, dataFileListStore);
+			if(team == Team.NONE)
+				return store;
+			
+			template = team == Team.LOCAL?LocalTeamTemplate:VisitorTeamTemplate;
+			
+			foreach(var player in template) {
+				/* Add a root in the tree with the option name */
+				var iter = store.AppendValues(player);
+				dict.Add(player, iter);
 			}
-			return dataFileListStore;
+			
+			foreach (var play in playsList) {
+				foreach (var player in play.Players)
+					store.AppendValues(dict[player], new object[1] {play});
+			}
+			return store;
 		}
 		#endregion
 	}
diff --git a/LongoMatch/Store/Tag.cs b/LongoMatch/Store/Tag.cs
index 0f6ccc2..564e5ff 100644
--- a/LongoMatch/Store/Tag.cs
+++ b/LongoMatch/Store/Tag.cs
@@ -17,66 +17,45 @@
 //
 
 using System;
+using System.Collections.Generic;
+
 using LongoMatch.Common;
 
 namespace LongoMatch.Store
 {
 
 	[Serializable]
-	public class Tag
+	public class Tag<T>
 	{
 		public Tag() {
 		}
 
-		public string Name {
+		public string SubCategory {
 			get;
 			set;
 		}
-
-		public object Value {
+		
+		public T Value {
 			get;
 			set;
 		}
 	}
 
 	[Serializable]
-	public class StringTag
+	public class StringTag: Tag<string>
 	{
-		public StringTag() {
-		}
-
-		public string Name {
-			get;
-			set;
-		}
-
-		public string Value {
-			get;
-			set;
-		}
+		public StringTag() {}
 	}
 
 	[Serializable]
-	public class PlayerTag:Tag
+	public class PlayerTag: Tag<Player>
 	{
-		public PlayerTag() {
-		}
-
-		public new Player Value {
-			get;
-			set;
-		}
+		public PlayerTag() {}
 	}
 
 	[Serializable]
-	public class TeamTag:Tag
+	public class TeamTag: Tag<Team>
 	{
-		public TeamTag() {
-		}
-
-		public new Team Value {
-			get;
-			set;
-		}
+		public TeamTag() {}
 	}
 }
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.PlayersTaggerWidget.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.PlayersTaggerWidget.cs
new file mode 100644
index 0000000..eaa1748
--- /dev/null
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.PlayersTaggerWidget.cs
@@ -0,0 +1,19 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace LongoMatch.Gui.Component
+{
+	public partial class PlayersTaggerWidget
+	{
+		protected virtual void Build ()
+		{
+			global::Stetic.Gui.Initialize (this);
+			// Widget LongoMatch.Gui.Component.PlayersTaggerWidget
+			global::Stetic.BinContainer.Attach (this);
+			this.Name = "LongoMatch.Gui.Component.PlayersTaggerWidget";
+			if ((this.Child != null)) {
+				this.Child.ShowAll ();
+			}
+			this.Hide ();
+		}
+	}
+}
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.StringTaggerWidget.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.StringTaggerWidget.cs
new file mode 100644
index 0000000..a606ae1
--- /dev/null
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.StringTaggerWidget.cs
@@ -0,0 +1,46 @@
+
+// This file has been generated by the GUI designer. Do not modify.
+namespace LongoMatch.Gui.Component
+{
+	public partial class StringTaggerWidget
+	{
+		private global::Gtk.Frame frame;
+
+		private global::Gtk.Alignment GtkAlignment;
+
+		private global::Gtk.HButtonBox buttonsbox;
+
+		private global::Gtk.Label GtkLabel;
+
+		protected virtual void Build ()
+		{
+			global::Stetic.Gui.Initialize (this);
+			// Widget LongoMatch.Gui.Component.StringTaggerWidget
+			global::Stetic.BinContainer.Attach (this);
+			this.Name = "LongoMatch.Gui.Component.StringTaggerWidget";
+			// Container child LongoMatch.Gui.Component.StringTaggerWidget.Gtk.Container+ContainerChild
+			this.frame = new global::Gtk.Frame ();
+			this.frame.Name = "frame";
+			this.frame.ShadowType = ((global::Gtk.ShadowType)(0));
+			// Container child frame.Gtk.Container+ContainerChild
+			this.GtkAlignment = new global::Gtk.Alignment (0f, 0f, 1f, 1f);
+			this.GtkAlignment.Name = "GtkAlignment";
+			this.GtkAlignment.LeftPadding = ((uint)(12));
+			// Container child GtkAlignment.Gtk.Container+ContainerChild
+			this.buttonsbox = new global::Gtk.HButtonBox ();
+			this.buttonsbox.Name = "buttonsbox";
+			this.GtkAlignment.Add (this.buttonsbox);
+			this.frame.Add (this.GtkAlignment);
+			this.GtkLabel = new global::Gtk.Label ();
+			this.GtkLabel.Name = "GtkLabel";
+			this.GtkLabel.LabelProp = global::Mono.Unix.Catalog.GetString ("<b>GtkFrame</b>");
+			this.GtkLabel.UseMarkup = true;
+			this.frame.LabelWidget = this.GtkLabel;
+			this.Add (this.frame);
+			if ((this.Child != null)) {
+				this.Child.ShowAll ();
+			}
+			this.Hide ();
+		}
+	}
+}
diff --git a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs
index 2942355..0fb880e 100644
--- a/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs
+++ b/LongoMatch/gtk-gui/LongoMatch.Gui.Component.TaggerWidget.cs
@@ -6,18 +6,10 @@ namespace LongoMatch.Gui.Component
 	{
 		private global::Gtk.VBox vbox2;
 
-		private global::Gtk.Label label1;
-
 		private global::Gtk.ScrolledWindow scrolledwindow1;
 
 		private global::Gtk.Table table1;
 
-		private global::Gtk.HBox hbox1;
-
-		private global::Gtk.Entry entry1;
-
-		private global::Gtk.Button tagbutton;
-
 		protected virtual void Build ()
 		{
 			global::Stetic.Gui.Initialize (this);
@@ -29,84 +21,29 @@ namespace LongoMatch.Gui.Component
 			this.vbox2.Name = "vbox2";
 			this.vbox2.Spacing = 6;
 			// Container child vbox2.Gtk.Box+BoxChild
-			this.label1 = new global::Gtk.Label ();
-			this.label1.Name = "label1";
-			this.label1.LabelProp = global::Mono.Unix.Catalog.GetString ("<b>You haven't tagged any play yet.</b>\nYou can add new tags using the text entry and clicking \"Add Tag\"");
-			this.label1.UseMarkup = true;
-			this.label1.Justify = ((global::Gtk.Justification)(2));
-			this.vbox2.Add (this.label1);
-			global::Gtk.Box.BoxChild w1 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.label1]));
-			w1.Position = 0;
-			// Container child vbox2.Gtk.Box+BoxChild
 			this.scrolledwindow1 = new global::Gtk.ScrolledWindow ();
 			this.scrolledwindow1.CanFocus = true;
 			this.scrolledwindow1.Name = "scrolledwindow1";
 			this.scrolledwindow1.ShadowType = ((global::Gtk.ShadowType)(1));
 			// Container child scrolledwindow1.Gtk.Container+ContainerChild
-			global::Gtk.Viewport w2 = new global::Gtk.Viewport ();
-			w2.ShadowType = ((global::Gtk.ShadowType)(0));
+			global::Gtk.Viewport w1 = new global::Gtk.Viewport ();
+			w1.ShadowType = ((global::Gtk.ShadowType)(0));
 			// Container child GtkViewport.Gtk.Container+ContainerChild
 			this.table1 = new global::Gtk.Table (((uint)(3)), ((uint)(3)), false);
 			this.table1.Name = "table1";
 			this.table1.RowSpacing = ((uint)(6));
 			this.table1.ColumnSpacing = ((uint)(6));
-			w2.Add (this.table1);
-			this.scrolledwindow1.Add (w2);
+			w1.Add (this.table1);
+			this.scrolledwindow1.Add (w1);
 			this.vbox2.Add (this.scrolledwindow1);
-			global::Gtk.Box.BoxChild w5 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.scrolledwindow1]));
-			w5.Position = 1;
-			// Container child vbox2.Gtk.Box+BoxChild
-			this.hbox1 = new global::Gtk.HBox ();
-			this.hbox1.Name = "hbox1";
-			this.hbox1.Spacing = 6;
-			// Container child hbox1.Gtk.Box+BoxChild
-			this.entry1 = new global::Gtk.Entry ();
-			this.entry1.CanFocus = true;
-			this.entry1.Name = "entry1";
-			this.entry1.IsEditable = true;
-			this.entry1.InvisibleChar = 'â?¢';
-			this.hbox1.Add (this.entry1);
-			global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.entry1]));
-			w6.Position = 0;
-			// Container child hbox1.Gtk.Box+BoxChild
-			this.tagbutton = new global::Gtk.Button ();
-			this.tagbutton.CanFocus = true;
-			this.tagbutton.Name = "tagbutton";
-			this.tagbutton.UseUnderline = true;
-			// Container child tagbutton.Gtk.Container+ContainerChild
-			global::Gtk.Alignment w7 = new global::Gtk.Alignment (0.5f, 0.5f, 0f, 0f);
-			// Container child GtkAlignment.Gtk.Container+ContainerChild
-			global::Gtk.HBox w8 = new global::Gtk.HBox ();
-			w8.Spacing = 2;
-			// Container child GtkHBox.Gtk.Container+ContainerChild
-			global::Gtk.Image w9 = new global::Gtk.Image ();
-			w9.Pixbuf = global::Stetic.IconLoader.LoadIcon (this, "gtk-add", global::Gtk.IconSize.Dialog);
-			w8.Add (w9);
-			// Container child GtkHBox.Gtk.Container+ContainerChild
-			global::Gtk.Label w11 = new global::Gtk.Label ();
-			w11.LabelProp = global::Mono.Unix.Catalog.GetString ("Add Tag");
-			w11.UseUnderline = true;
-			w8.Add (w11);
-			w7.Add (w8);
-			this.tagbutton.Add (w7);
-			this.hbox1.Add (this.tagbutton);
-			global::Gtk.Box.BoxChild w15 = ((global::Gtk.Box.BoxChild)(this.hbox1[this.tagbutton]));
-			w15.Position = 1;
-			w15.Expand = false;
-			w15.Fill = false;
-			this.vbox2.Add (this.hbox1);
-			global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.hbox1]));
-			w16.Position = 2;
-			w16.Expand = false;
-			w16.Fill = false;
+			global::Gtk.Box.BoxChild w4 = ((global::Gtk.Box.BoxChild)(this.vbox2[this.scrolledwindow1]));
+			w4.Position = 0;
 			this.Add (this.vbox2);
 			if ((this.Child != null)) {
 				this.Child.ShowAll ();
 			}
 			this.scrolledwindow1.Hide ();
 			this.Hide ();
-			this.entry1.Activated += new global::System.EventHandler (this.OnEntry1Activated);
-			this.tagbutton.Clicked += new global::System.EventHandler (this.OnTagbuttonClicked);
 		}
 	}
 }
diff --git a/LongoMatch/gtk-gui/gui.stetic b/LongoMatch/gtk-gui/gui.stetic
index b218510..fbb9aee 100644
--- a/LongoMatch/gtk-gui/gui.stetic
+++ b/LongoMatch/gtk-gui/gui.stetic
@@ -5401,19 +5401,6 @@ Show-&gt;&lt;b&gt; S&lt;/b&gt;
         <property name="MemberName" />
         <property name="Spacing">6</property>
         <child>
-          <widget class="Gtk.Label" id="label1">
-            <property name="MemberName" />
-            <property name="LabelProp" translatable="yes">&lt;b&gt;You haven't tagged any play yet.&lt;/b&gt;
-You can add new tags using the text entry and clicking "Add Tag"</property>
-            <property name="UseMarkup">True</property>
-            <property name="Justify">Center</property>
-          </widget>
-          <packing>
-            <property name="Position">0</property>
-            <property name="AutoSize">False</property>
-          </packing>
-        </child>
-        <child>
           <widget class="Gtk.ScrolledWindow" id="scrolledwindow1">
             <property name="MemberName" />
             <property name="Visible">False</property>
@@ -5463,50 +5450,8 @@ You can add new tags using the text entry and clicking "Add Tag"</property>
             </child>
           </widget>
           <packing>
-            <property name="Position">1</property>
-            <property name="AutoSize">True</property>
-          </packing>
-        </child>
-        <child>
-          <widget class="Gtk.HBox" id="hbox1">
-            <property name="MemberName" />
-            <property name="Spacing">6</property>
-            <child>
-              <widget class="Gtk.Entry" id="entry1">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="IsEditable">True</property>
-                <property name="InvisibleChar">â?¢</property>
-                <signal name="Activated" handler="OnEntry1Activated" />
-              </widget>
-              <packing>
-                <property name="Position">0</property>
-                <property name="AutoSize">True</property>
-              </packing>
-            </child>
-            <child>
-              <widget class="Gtk.Button" id="tagbutton">
-                <property name="MemberName" />
-                <property name="CanFocus">True</property>
-                <property name="Type">TextAndIcon</property>
-                <property name="Icon">stock:gtk-add Dialog</property>
-                <property name="Label" translatable="yes">Add Tag</property>
-                <property name="UseUnderline">True</property>
-                <signal name="Clicked" handler="OnTagbuttonClicked" />
-              </widget>
-              <packing>
-                <property name="Position">1</property>
-                <property name="AutoSize">True</property>
-                <property name="Expand">False</property>
-                <property name="Fill">False</property>
-              </packing>
-            </child>
-          </widget>
-          <packing>
-            <property name="Position">2</property>
+            <property name="Position">0</property>
             <property name="AutoSize">True</property>
-            <property name="Expand">False</property>
-            <property name="Fill">False</property>
           </packing>
         </child>
       </widget>
@@ -6320,4 +6265,98 @@ You can continue with the current capture, cancel it or save your project.
       </widget>
     </child>
   </widget>
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.PlayersTaggerWidget" design-size="300 300">
+    <property name="MemberName" />
+    <property name="Visible">False</property>
+    <child>
+      <widget class="Gtk.ScrolledWindow" id="scrolledwindow1">
+        <property name="MemberName" />
+        <property name="CanFocus">True</property>
+        <property name="ShadowType">In</property>
+        <child>
+          <widget class="Gtk.Viewport" id="GtkViewport">
+            <property name="MemberName" />
+            <property name="ShadowType">None</property>
+            <child>
+              <widget class="Gtk.Table" id="table1">
+                <property name="MemberName" />
+                <property name="NRows">3</property>
+                <property name="NColumns">3</property>
+                <property name="RowSpacing">6</property>
+                <property name="ColumnSpacing">6</property>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+                <child>
+                  <placeholder />
+                </child>
+              </widget>
+            </child>
+          </widget>
+        </child>
+      </widget>
+    </child>
+  </widget>
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.PlayersTaggerWidget" design-size="300 300">
+    <property name="MemberName" />
+    <property name="Visible">False</property>
+    <child>
+      <placeholder />
+    </child>
+  </widget>
+  <widget class="Gtk.Bin" id="LongoMatch.Gui.Component.StringTaggerWidget" design-size="300 98">
+    <property name="MemberName" />
+    <property name="Visible">False</property>
+    <child>
+      <widget class="Gtk.Frame" id="frame">
+        <property name="MemberName" />
+        <property name="ShadowType">None</property>
+        <child>
+          <widget class="Gtk.Alignment" id="GtkAlignment">
+            <property name="MemberName" />
+            <property name="Xalign">0</property>
+            <property name="Yalign">0</property>
+            <property name="LeftPadding">12</property>
+            <child>
+              <widget class="Gtk.HButtonBox" id="buttonsbox">
+                <property name="MemberName" />
+                <property name="Size">0</property>
+              </widget>
+            </child>
+          </widget>
+        </child>
+        <child>
+          <widget class="Gtk.Label" id="GtkLabel">
+            <property name="MemberName" />
+            <property name="LabelProp" translatable="yes">&lt;b&gt;GtkFrame&lt;/b&gt;</property>
+            <property name="UseMarkup">True</property>
+          </widget>
+          <packing>
+            <property name="type">label_item</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </stetic-interface>
\ No newline at end of file



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