[f-spot/icon-view-cleanup] Clean up PhotoList



commit fa7340743abcb91cffc1805af9d88be190c70866
Author: Mike Gemünde <mike gemuende de>
Date:   Wed Sep 8 09:39:22 2010 +0200

    Clean up PhotoList
    
    Make Constructors more generic, remove unused method AddAll() (which
    btw had a strange behavior) and reformat the file (whitespaces).

 src/Core/FSpot.Core/FSpot.Core/PhotoList.cs |  209 +++++++++++++--------------
 1 files changed, 102 insertions(+), 107 deletions(-)
---
diff --git a/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs b/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs
index 7a597d9..185b767 100644
--- a/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs
+++ b/src/Core/FSpot.Core/FSpot.Core/PhotoList.cs
@@ -2,117 +2,112 @@
  * FSpot.PhotoList.cs
  *
  * Author(s):
- *	Larry Ewing
+ *  Larry Ewing
  *
  * This is free software, See COPYING for details
  */
 
 using System.Collections.Generic;
 
-namespace FSpot.Core {
-
-	public class PhotoList : IBrowsableCollection {
-		protected List<IPhoto> list;
-		IPhoto [] cache;
-
-		public PhotoList (IPhoto [] photos)
-		{
-			list = new List<IPhoto> (photos);
-		}
-
-		public PhotoList ()
-		{
-			list = new List<IPhoto> ();
-		}
-
-		public int Count {
-			get { return list.Count; }
-		}
-
-		public void Clear ()
-		{
-			list.Clear ();
-			Reload ();
-		}
-
-		public int Capacity {
-			set { list.Capacity = value; }
-		}
-
-		public void AddAll (List<IPhoto> photos)
-		{
-			list = photos;
-			Reload ();
-		}
-
-		public void Add (IPhoto photo)
-		{
-			list.Add (photo);
-			Reload ();
-		}
-
-		public void Add (IPhoto [] items)
-		{
-			list.AddRange (items);
-			Reload ();
-		}
-
-		public int IndexOf (IPhoto item)
-		{
-			return list.IndexOf (item);
-		}
-
-		public bool Contains (IPhoto item)
-		{
-			return list.Contains (item);
-		}
-
-		public IPhoto this [int index] {
-			get { return list [index]; }
-			set {
-				list [index] = value;
-				MarkChanged (index, FullInvalidate.Instance);
-			}
-		}
-
-		public void Sort (IComparer<IPhoto> compare)
-		{
-			list.Sort (compare);
-			Reload ();
-		}
-
-		public void Reload ()
-		{
-			cache = null;
-			if (Changed != null)
-				Changed (this);
-		}
-
-		public void MarkChanged (int num, IBrowsableItemChanges changes)
-		{
-			MarkChanged (new BrowsableEventArgs (num, changes));
-		}
-
-		public void MarkChanged (BrowsableEventArgs args)
-		{
-			if (ItemsChanged != null)
-				ItemsChanged (this, args);
-		}
-
-		public IPhoto [] Items {
-			get {
-				if (cache == null)
-					cache = list.ToArray ();
-
-				return cache;
-			}
-			set {
-				list.Clear ();
-				Add (value);
-			}
-		}
-
-		public event IBrowsableCollectionChangedHandler Changed;
-		public event IBrowsableCollectionItemsChangedHandler ItemsChanged;
-	}
+namespace FSpot.Core
+{
+
+    public class PhotoList : IBrowsableCollection
+    {
+        protected List<IPhoto> list;
+        private IPhoto[] cache;
+
+        public PhotoList (IEnumerable<IPhoto> photos)
+        {
+            list = new List<IPhoto> (photos);
+        }
+
+        public PhotoList (params IPhoto[] photos) : this(photos as IEnumerable<IPhoto>)
+        {
+        }
+
+        public int Count {
+            get { return list.Count; }
+        }
+
+        public void Clear ()
+        {
+            list.Clear ();
+            Reload ();
+        }
+
+        public int Capacity {
+            set { list.Capacity = value; }
+        }
+
+        public void Add (IPhoto photo)
+        {
+            list.Add (photo);
+            Reload ();
+        }
+
+        public void Add (IEnumerable<IPhoto> items)
+        {
+            list.AddRange (items);
+            Reload ();
+        }
+
+        public int IndexOf (IPhoto item)
+        {
+            return list.IndexOf (item);
+        }
+
+        public bool Contains (IPhoto item)
+        {
+            return list.Contains (item);
+        }
+
+        public IPhoto this[int index] {
+            get { return list[index]; }
+            set {
+                list[index] = value;
+                MarkChanged (index, FullInvalidate.Instance);
+            }
+        }
+
+        public void Sort (IComparer<IPhoto> compare)
+        {
+            list.Sort (compare);
+            Reload ();
+        }
+
+        public void Reload ()
+        {
+            cache = null;
+            if (Changed != null)
+                Changed (this);
+        }
+
+        public void MarkChanged (int num, IBrowsableItemChanges changes)
+        {
+            MarkChanged (new BrowsableEventArgs (num, changes));
+        }
+
+        public void MarkChanged (BrowsableEventArgs args)
+        {
+            if (ItemsChanged != null)
+                ItemsChanged (this, args);
+        }
+
+        public IPhoto[] Items {
+            get {
+                if (cache == null)
+                    cache = list.ToArray ();
+                
+                return cache;
+            }
+            set {
+                list.Clear ();
+                Add (value);
+            }
+        }
+
+        public event IBrowsableCollectionChangedHandler Changed;
+        public event IBrowsableCollectionItemsChangedHandler ItemsChanged;
+    }
 }



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