[blam] Channel: Remove items on channel removal



commit 9830d65c86f4ed88d590a7d8e7d473e78e2c2963
Author: Carlos Martín Nieto <carlos cmartin tk>
Date:   Tue Mar 1 13:09:19 2011 +0100

    Channel: Remove items on channel removal
    
    Signed-off-by: Carlos Martín Nieto <carlos cmartin tk>

 src/Channel.cs      |   11 +++++++++++
 src/ChannelGroup.cs |    7 +++++++
 src/ChannelList.cs  |    1 +
 3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/Channel.cs b/src/Channel.cs
index 6af9322..4f318c0 100644
--- a/src/Channel.cs
+++ b/src/Channel.cs
@@ -23,6 +23,7 @@ namespace Imendio.Blam {
         bool MarkAsRead();
         Item GetItem(string id);
         event ChannelEventHandler Updated;
+        void RemoveItems();
     }
 
     public class Channel : IChannel {
@@ -165,6 +166,16 @@ namespace Imendio.Blam {
             }
         }
 
+		public void RemoveItems()
+		{
+			ItemStore store = ItemStore.GetInstance();
+			lock(obj){
+				foreach(string id in item_list){
+					store.Remove(id);
+				}
+			}
+		}
+
 		public bool MarkAsRead ()
 		{
 			bool updated = false;
diff --git a/src/ChannelGroup.cs b/src/ChannelGroup.cs
index 83a1e8c..11fce7d 100644
--- a/src/ChannelGroup.cs
+++ b/src/ChannelGroup.cs
@@ -116,6 +116,13 @@ namespace Imendio.Blam
 			Channels.Add(chan);
 		}
 
+		public void RemoveItems()
+		{
+			foreach(Channel chan in Channels){
+				chan.RemoveItems();
+			}
+		}
+
         public ChannelGroup() : base()
         {
             if(Channels == null)
diff --git a/src/ChannelList.cs b/src/ChannelList.cs
index fe020c2..8e7521d 100644
--- a/src/ChannelList.cs
+++ b/src/ChannelList.cs
@@ -255,6 +255,7 @@ namespace Imendio.Blam {
                 this.Selection.Changed -= selectionChangedHandler;
 
                 valid = (this.Model as TreeStore).Remove(ref iter);
+                channel.RemoveItems();
 
                 this.Selection.Changed += selectionChangedHandler;
 



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