[longomatch] Add support for filtering tags
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add support for filtering tags
- Date: Mon, 22 Dec 2014 18:11:03 +0000 (UTC)
commit 2d089f5fc11cac9afd5549f14da6f832b16b5c00
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Dec 22 19:03:24 2014 +0100
Add support for filtering tags
LongoMatch.Core/Common/EventsFilter.cs | 28 ++++++++++++++++++-
.../Gui/TreeView/CategoriesFilterTreeView.cs | 18 ++++++++++--
2 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsFilter.cs b/LongoMatch.Core/Common/EventsFilter.cs
index 7767938..4c8262d 100644
--- a/LongoMatch.Core/Common/EventsFilter.cs
+++ b/LongoMatch.Core/Common/EventsFilter.cs
@@ -29,6 +29,7 @@ namespace LongoMatch.Core.Common
public event FilterUpdatedHandler FilterUpdated;
Dictionary<EventType, List<Tag>> eventsFilter;
+ List<Tag> tagsFilter;
List<Player> playersFilter;
List<Period> periodsFilter;
List<Timer> timersFilter;
@@ -40,6 +41,7 @@ namespace LongoMatch.Core.Common
eventsFilter = new Dictionary<EventType, List<Tag>> ();
playersFilter = new List<Player> ();
periodsFilter = new List<Period> ();
+ tagsFilter = new List<Tag> ();
timersFilter = new List<Timer> ();
ClearAll ();
UpdateFilters ();
@@ -76,6 +78,7 @@ namespace LongoMatch.Core.Common
playersFilter.Clear ();
periodsFilter.Clear ();
timersFilter.Clear ();
+ tagsFilter.Clear ();
if (update)
Update ();
}
@@ -116,6 +119,16 @@ namespace LongoMatch.Core.Common
Update ();
}
+ public void FilterTag (Tag tag, bool visible)
+ {
+ if (visible) {
+ if (!tagsFilter.Contains (tag))
+ tagsFilter.Add (tag);
+ } else {
+ if (tagsFilter.Contains (tag))
+ tagsFilter.Remove (tag);
+ }
+ }
public void FilterTimer (Timer timer, bool visible)
{
if (visible) {
@@ -193,7 +206,7 @@ namespace LongoMatch.Core.Common
void UpdateVisiblePlays ()
{
- bool cat_match = true, player_match = true;
+ bool cat_match = true, tag_match = true, player_match = true;
bool period_match = true, timer_match = true;
VisiblePlays = new List<TimelineEvent> ();
@@ -212,6 +225,17 @@ namespace LongoMatch.Core.Common
}
}
+ if (tagsFilter.Count > 0) {
+ if (play.Tags.Count > 0 && play.Tags [0].Value == "Layup") {
+ Console.WriteLine (tagsFilter.Intersect (play.Tags).Count ());
+ }
+ if (tagsFilter.Intersect (play.Tags).Count () == 0) {
+ tag_match = false;
+ } else {
+ tag_match = true;
+ }
+ }
+
if (play.Players.Count == 0 && VisiblePlayers.Count ==
project.LocalTeamTemplate.PlayingPlayersList.Count +
project.VisitorTeamTemplate.PlayingPlayersList.Count) {
@@ -240,7 +264,7 @@ namespace LongoMatch.Core.Common
}
}
- if (player_match && cat_match && period_match && timer_match) {
+ if (player_match && cat_match && tag_match && period_match && timer_match) {
VisiblePlays.Add (play);
}
}
diff --git a/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
b/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
index f2e792b..5a1cd0a 100644
--- a/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
@@ -16,12 +16,11 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
using System;
+using System.Linq;
using Gtk;
using Mono.Unix;
using LongoMatch.Core.Common;
-using LongoMatch.Core.Interfaces;
using LongoMatch.Core.Store;
-using LongoMatch.Core.Store.Templates;
namespace LongoMatch.Gui.Component
{
@@ -69,6 +68,15 @@ namespace LongoMatch.Gui.Component
}
}
}
+
+ var tagsByGroup = project.Dashboard.CommonTagsByGroup.ToDictionary (x => x.Key, x =>
x.Value);
+ foreach (string grp in tagsByGroup.Keys) {
+ TreeIter grpIter = store.AppendValues (new StringObject (grp), false);
+ foreach (Tag tag in tagsByGroup[grp]) {
+ store.AppendValues (grpIter, tag, false);
+ }
+ }
+
filter.IgnoreUpdates = false;
filter.Update ();
Model = store;
@@ -83,7 +91,11 @@ namespace LongoMatch.Gui.Component
if (o is Tag) {
EventType evType = store.GetValue (parent, 0) as EventType;
- filter.FilterEventTag (evType, o as Tag, active);
+ if (evType != null) {
+ filter.FilterEventTag (evType, o as Tag, active);
+ } else {
+ filter.FilterTag (o as Tag, active);
+ }
} else if (o is EventType) {
filter.FilterEventType (o as EventType, active);
} else if (o is Period) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]