[longomatch] Fix events filtering when the team has players not playing



commit e37c710ef00c3572c4541a1b8919a048a1a375cc
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Thu Dec 11 14:54:37 2014 +0100

    Fix events filtering when the team has players not playing
    
    Use the list of  playing players instead of the list of the team's
    players for the events filter.

 LongoMatch.Core/Common/EventsFilter.cs             |   17 +++++++++++++----
 .../Gui/TreeView/CategoriesFilterTreeView.cs       |    3 +++
 .../Gui/TreeView/PlayersFilterTreeView.cs          |    3 +++
 3 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsFilter.cs b/LongoMatch.Core/Common/EventsFilter.cs
index 5eaff36..7767938 100644
--- a/LongoMatch.Core/Common/EventsFilter.cs
+++ b/LongoMatch.Core/Common/EventsFilter.cs
@@ -50,6 +50,11 @@ namespace LongoMatch.Core.Common
                        get;
                }
 
+               public bool IgnoreUpdates {
+                       set;
+                       get;
+               }
+
                public List<EventType> VisibleEventTypes {
                        get;
                        protected set;
@@ -154,8 +159,10 @@ namespace LongoMatch.Core.Common
 
                public void Update ()
                {
-                       UpdateFilters ();
-                       EmitFilterUpdated ();
+                       if (!IgnoreUpdates) {
+                               UpdateFilters ();
+                               EmitFilterUpdated ();
+                       }
                }
 
                void UpdateFilters ()
@@ -168,7 +175,8 @@ namespace LongoMatch.Core.Common
                void UpdateVisiblePlayers ()
                {
                        if (playersFilter.Count == 0) {
-                               VisiblePlayers = project.LocalTeamTemplate.List.Concat 
(project.VisitorTeamTemplate.List).ToList ();
+                               VisiblePlayers = project.LocalTeamTemplate.PlayingPlayersList.Concat (
+                                       project.VisitorTeamTemplate.PlayingPlayersList).ToList ();
                        } else {
                                VisiblePlayers = playersFilter.ToList ();
                        }
@@ -205,7 +213,8 @@ namespace LongoMatch.Core.Common
                                }
 
                                if (play.Players.Count == 0 && VisiblePlayers.Count == 
-                                       project.LocalTeamTemplate.List.Count + 
project.VisitorTeamTemplate.List.Count) {
+                                   project.LocalTeamTemplate.PlayingPlayersList.Count +
+                                   project.VisitorTeamTemplate.PlayingPlayersList.Count) {
                                        player_match = true;
                                } else {
                                        player_match = VisiblePlayers.Intersect (play.Players).Count () != 0;
diff --git a/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs 
b/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
index a51fec7..f2e792b 100644
--- a/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
@@ -47,6 +47,7 @@ namespace LongoMatch.Gui.Component
                        TreeIter catIter;
                        store = new TreeStore (typeof(object), typeof(bool));
                        
+                       filter.IgnoreUpdates = true;
                        /* Periods */
                        catIter = store.AppendValues (new StringObject (Catalog.GetString ("Periods")), 
false);
                        foreach (Period p in project.Periods) {
@@ -68,6 +69,8 @@ namespace LongoMatch.Gui.Component
                                        }
                                }
                        }
+                       filter.IgnoreUpdates = false;
+                       filter.Update ();
                        Model = store;
                }
 
diff --git a/LongoMatch.GUI/Gui/TreeView/PlayersFilterTreeView.cs 
b/LongoMatch.GUI/Gui/TreeView/PlayersFilterTreeView.cs
index a789837..37b9ab6 100644
--- a/LongoMatch.GUI/Gui/TreeView/PlayersFilterTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/PlayersFilterTreeView.cs
@@ -57,6 +57,7 @@ namespace LongoMatch.Gui.Component
                        store.SetValue(localIter, 1, false);
                        store.SetValue(visitorIter, 1, false);
                        
+                       filter.IgnoreUpdates = true;
                        foreach (Player player in local.PlayingPlayersList) {
                                filter.FilterPlayer (player, true);
                                store.AppendValues (localIter, player, true);
@@ -66,6 +67,8 @@ namespace LongoMatch.Gui.Component
                                filter.FilterPlayer (player, true);
                                store.AppendValues (visitorIter, player, true);
                        }
+                       filter.IgnoreUpdates = false;
+                       filter.Update ();
                        Model = store;
                }
  


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