[longomatch] Add suport for timers filters
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add suport for timers filters
- Date: Fri, 10 Oct 2014 12:35:27 +0000 (UTC)
commit f8f79fb31cb5b6d3273621286090f96df86a7b7a
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Oct 9 16:38:57 2014 +0200
Add suport for timers filters
LongoMatch.Core/Common/EventsFilter.cs | 32 ++++++++++++++++++-
.../Gui/TreeView/CategoriesFilterTreeView.cs | 11 +++++-
2 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsFilter.cs b/LongoMatch.Core/Common/EventsFilter.cs
index 4732946..5eaff36 100644
--- a/LongoMatch.Core/Common/EventsFilter.cs
+++ b/LongoMatch.Core/Common/EventsFilter.cs
@@ -31,6 +31,7 @@ namespace LongoMatch.Core.Common
Dictionary<EventType, List<Tag>> eventsFilter;
List<Player> playersFilter;
List<Period> periodsFilter;
+ List<Timer> timersFilter;
Project project;
public EventsFilter (Project project)
@@ -39,6 +40,7 @@ namespace LongoMatch.Core.Common
eventsFilter = new Dictionary<EventType, List<Tag>> ();
playersFilter = new List<Player> ();
periodsFilter = new List<Period> ();
+ timersFilter = new List<Timer> ();
ClearAll ();
UpdateFilters ();
}
@@ -68,6 +70,7 @@ namespace LongoMatch.Core.Common
eventsFilter.Clear ();
playersFilter.Clear ();
periodsFilter.Clear ();
+ timersFilter.Clear ();
if (update)
Update ();
}
@@ -108,6 +111,18 @@ namespace LongoMatch.Core.Common
Update ();
}
+ public void FilterTimer (Timer timer, bool visible)
+ {
+ if (visible) {
+ if (!timersFilter.Contains (timer))
+ timersFilter.Add (timer);
+ } else {
+ if (timersFilter.Contains (timer))
+ timersFilter.Remove (timer);
+ }
+ Update ();
+ }
+
public void FilterEventTag (EventType evType, Tag tag, bool visible)
{
List<Tag> tags;
@@ -170,7 +185,9 @@ namespace LongoMatch.Core.Common
void UpdateVisiblePlays ()
{
- bool cat_match = true, player_match = true, period_match = true;
+ bool cat_match = true, player_match = true;
+ bool period_match = true, timer_match = true;
+
VisiblePlays = new List<TimelineEvent> ();
foreach (TimelineEvent play in project.Timeline) {
@@ -194,6 +211,17 @@ namespace LongoMatch.Core.Common
player_match = VisiblePlayers.Intersect (play.Players).Count () != 0;
}
+ if (timersFilter.Count != 0) {
+ timer_match = false;
+ }
+ foreach (Timer t in timersFilter) {
+ foreach (TimeNode tn in t.Nodes) {
+ if (tn.Join (play) != null) {
+ timer_match = true;
+ }
+ }
+ }
+
if (periodsFilter.Count != 0) {
period_match = false;
}
@@ -203,7 +231,7 @@ namespace LongoMatch.Core.Common
}
}
- if (player_match && cat_match && period_match) {
+ if (player_match && cat_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 3c95a50..056a95b 100644
--- a/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
+++ b/LongoMatch.GUI/Gui/TreeView/CategoriesFilterTreeView.cs
@@ -54,6 +54,11 @@ namespace LongoMatch.Gui.Component
store.AppendValues (catIter, p, false);
}
+ catIter = store.AppendValues (new StringObject (Catalog.GetString ("Timers")), false);
+ foreach (Timer t in project.Timers) {
+ store.AppendValues (catIter, t, false);
+ }
+
foreach (EventType evType in project.EventTypes) {
catIter = store.AppendValues (evType, true);
filter.FilterEventType (evType, true);
@@ -81,6 +86,8 @@ namespace LongoMatch.Gui.Component
filter.FilterEventType (o as EventType, active);
} else if (o is Period) {
filter.FilterPeriod (o as Period, active);
+ } else if (o is Timer) {
+ filter.FilterTimer (o as Timer, active);
}
store.SetValue (iter, 1, active);
@@ -117,8 +124,8 @@ namespace LongoMatch.Gui.Component
text = evType.Name;
} else if (obj is Tag) {
text = (obj as Tag).Value;
- } else if (obj is Period) {
- text = (obj as Period).Name;
+ } else if (obj is Timer) {
+ text = (obj as Timer).Name;
} else if (obj is StringObject) {
text = (obj as StringObject).Text;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]