[longomatch] Remove even types with no events and no dashboard button
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Remove even types with no events and no dashboard button
- Date: Mon, 22 Dec 2014 19:10:20 +0000 (UTC)
commit a9cae73e5a85f4d13bea4375bf13ebc118b1765e
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Mon Dec 22 20:01:41 2014 +0100
Remove even types with no events and no dashboard button
When a button is removed in the dashboard, make sure we
also remove the event type from the project list
LongoMatch.Core/Store/Project.cs | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index ccca01c..7df1ac6 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -299,15 +299,27 @@ namespace LongoMatch.Core.Store
public void UpdateEventTypesAndTimers ()
{
+ IEnumerable<EventType> dashboardtypes, timelinetypes;
/* Timers */
IEnumerable<Timer> timers = Dashboard.List.OfType<TimerButton> ().Select (b =>
b.Timer);
Timers.AddRange (timers.Except (Timers));
- /* Event Types */
- IEnumerable<EventType> types = Dashboard.List.OfType<EventButton> ().Select (b =>
b.EventType);
- EventTypes.AddRange (types.Except (EventTypes));
- types = Timeline.Select (t => t.EventType).Distinct ().Except (EventTypes);
- EventTypes.AddRange (types.Except (EventTypes));
+ /* Update event types list that changes when the user adds or remove a
+ * a new button to the dashboard or after importing a project with events
+ * tagged with a different dashboard */
+ dashboardtypes = Dashboard.List.OfType<EventButton> ().Select (b => b.EventType);
+ /* Remove event types that have no events and are not in the dashboard anymore */
+ foreach (EventType evt in EventTypes.Except (dashboardtypes).ToList ()) {
+ if (evt == SubstitutionsEventType) {
+ continue;
+ }
+ if (Timeline.Count (e => e.EventType == evt) == 0) {
+ EventTypes.Remove (evt);
+ }
+ }
+ EventTypes.AddRange (dashboardtypes.Except (EventTypes));
+ timelinetypes = Timeline.Select (t => t.EventType).Distinct ().Except (EventTypes);
+ EventTypes.AddRange (timelinetypes.Except (EventTypes));
if (!EventTypes.Contains (SubstitutionsEventType)) {
EventTypes.Add (SubstitutionsEventType);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]