[longomatch/redesign3] Update players list on add/delete play



commit 6a78365692e0ec45871d880a5558ec8493606679
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Aug 19 00:11:46 2011 +0200

    Update players list on add/delete play

 LongoMatch/Gui/Component/PlayersListTreeWidget.cs |   47 ---------------------
 LongoMatch/Handlers/EventsManager.cs              |   18 ++++++--
 2 files changed, 14 insertions(+), 51 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/PlayersListTreeWidget.cs b/LongoMatch/Gui/Component/PlayersListTreeWidget.cs
index eff234c..03951e8 100644
--- a/LongoMatch/Gui/Component/PlayersListTreeWidget.cs
+++ b/LongoMatch/Gui/Component/PlayersListTreeWidget.cs
@@ -60,53 +60,6 @@ namespace LongoMatch.Gui.Component
 			}
 		}
 
-		public void RemovePlays(List<Play> plays) {
-			TreeIter iter, child;
-			TreeStore model;
-			List<TreeIter> removeIters;
-
-			if(template == null)
-				return;
-
-			removeIters = new List<TreeIter>();
-			model = (TreeStore)playerstreeview.Model;
-			model.GetIterFirst(out iter);
-			do {
-				if(!model.IterHasChild(iter))
-					continue;
-
-				model.IterChildren(out child, iter);
-				do {
-					Play play = (Play) model.GetValue(child,0);
-					if(plays.Contains(play)) {
-						removeIters.Add(child);
-					}
-				} while(model.IterNext(ref child));
-			} while(model.IterNext(ref iter));
-
-			for(int i=0; i < removeIters.Count; i++) {
-				iter = removeIters[i];
-				model.Remove(ref iter);
-			}
-		}
-
-
-		public void AddPlay(Play play, Player player) {
-			TreeIter iter;
-			TreeStore model;
-
-			if(template == null)
-				return;
-			model = (TreeStore)playerstreeview.Model;
-			model.GetIterFirst(out iter);
-			do {
-				if(model.GetValue(iter, 0) == player) {
-					model.AppendValues(iter, player);
-					break;
-				}
-			} while(model.IterNext(ref iter));
-		}
-
 		public void SetTeam(TeamTemplate template, TreeStore model) {
 			this.template = template;
 			playerstreeview.Model = model;
diff --git a/LongoMatch/Handlers/EventsManager.cs b/LongoMatch/Handlers/EventsManager.cs
index 4608662..83aeb6b 100644
--- a/LongoMatch/Handlers/EventsManager.cs
+++ b/LongoMatch/Handlers/EventsManager.cs
@@ -198,6 +198,8 @@ namespace LongoMatch
 			treewidget.AddPlay(play);
 			tagsTreeWidget.AddPlay(play);
 			timeline.AddPlay(play);
+			/* FIXME: Check performance */
+			UpdateTeamsModels();
 			timeline.QueueDraw();
 		}
 
@@ -281,6 +283,15 @@ namespace LongoMatch
 			tg.Run();
 			tg.Destroy();
 		}
+
+		private void UpdateTeamsModels() {
+			TreeStore local, visitor;
+		
+			openedProject.GetPlayersModel (out local, out visitor);
+			localPlayersList.SetTeam(openedProject.LocalTeamTemplate, local);
+			visitorPlayersList.SetTeam(openedProject.VisitorTeamTemplate, visitor);
+		}
+
 		
 		protected virtual void OnTimeNodeSelected(Play tNode)
 		{
@@ -318,11 +329,10 @@ namespace LongoMatch
 			treewidget.RemovePlays(plays);
 			timeline.RemovePlays(plays);
 			tagsTreeWidget.RemovePlays(plays);
-
-			localPlayersList.RemovePlays(plays);
-			visitorPlayersList.RemovePlays(plays);
-
 			openedProject.RemovePlays(plays);
+
+			/* FIXME: Check performance */
+			UpdateTeamsModels();
 			if(projectType == ProjectType.FileProject) {
 				this.player.CloseActualSegment();
 				MainClass.DB.UpdateProject(openedProject);



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