[f-spot/cleanup-backend: 9/24] Add Selection property to IBrowseableCollection



commit 010f6574459606f1dfbd6419578b3698e4c6a9c8
Author: Mike Gemünde <mike gemuende de>
Date:   Fri Jul 16 10:52:58 2010 +0200

    Add Selection property to IBrowseableCollection
    
    We are going closer to the Hyena models where every one provides
    its own selection. Therfore, it is added to IBrowseableCollection.
    Fun starts now by pointing the usage of selections to
    IBrowseableCollection.

 src/Core/IBrowsableCollection.cs |    5 +++++
 src/PhotoList.cs                 |   14 +++++++++++++-
 src/PhotoQuery.cs                |   11 +++++++++++
 3 files changed, 29 insertions(+), 1 deletions(-)
---
diff --git a/src/Core/IBrowsableCollection.cs b/src/Core/IBrowsableCollection.cs
index c81bc77..51cad8c 100644
--- a/src/Core/IBrowsableCollection.cs
+++ b/src/Core/IBrowsableCollection.cs
@@ -7,6 +7,8 @@
  * This is free software. See COPYING for details.
  */
 
+using FSpot.Collections;
+
 namespace FSpot
 {
 	public delegate void IBrowsableCollectionChangedHandler (IBrowsableCollection collection);
@@ -28,6 +30,9 @@ namespace FSpot
 			get;
 		}
 
+        PhotoSelection Selection { get; }
+
+
 		bool Contains (IBrowsableItem item);
 
 		// FIXME the Changed event needs to pass along information
diff --git a/src/PhotoList.cs b/src/PhotoList.cs
index c66212f..def871d 100644
--- a/src/PhotoList.cs
+++ b/src/PhotoList.cs
@@ -9,19 +9,25 @@
 
 using System.Collections.Generic;
 
+using FSpot.Collections;
+
 namespace FSpot {
 	public class PhotoList : IBrowsableCollection {
 		protected List<IBrowsableItem> list;
 		IBrowsableItem [] cache;
 
-		public PhotoList (IBrowsableItem [] photos)
+		public PhotoList (IEnumerable<IBrowsableItem> photos)
 		{
 			list = new List<IBrowsableItem> (photos);
+            Selection = new PhotoSelection (this);
+            Selection.MaxIndex = Count - 1;
 		}
 
 		public PhotoList ()
 		{
 			list = new List<IBrowsableItem> ();
+            Selection = new PhotoSelection (this);
+            Selection.MaxIndex = Count - 1;
 		}
 
 		public int Count {
@@ -82,6 +88,8 @@ namespace FSpot {
 
 		public void Reload ()
 		{
+            Selection.MaxIndex = Count - 1;
+
 			cache = null;
 			if (Changed != null)
 				Changed (this);
@@ -111,6 +119,10 @@ namespace FSpot {
 			}
 		}
 
+        public PhotoSelection Selection {
+            get; protected set;
+        }
+
 		public event IBrowsableCollectionChangedHandler Changed;
 		public event IBrowsableCollectionItemsChangedHandler ItemsChanged;
 	}
diff --git a/src/PhotoQuery.cs b/src/PhotoQuery.cs
index 7aceaa3..6816f8c 100644
--- a/src/PhotoQuery.cs
+++ b/src/PhotoQuery.cs
@@ -11,7 +11,10 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+
 using FSpot.Query;
+using FSpot.Collections;
+
 using Hyena;
 
 namespace FSpot {
@@ -84,6 +87,8 @@ namespace FSpot {
 			foreach (IQueryCondition condition in conditions)
 				SetCondition (condition);
 
+            Selection = new PhotoSelection (this);
+
 			RequestReload ();
 		}
 
@@ -276,6 +281,8 @@ namespace FSpot {
 			cache = new PhotoCache (store, temp_table);
 			reverse_lookup = new Dictionary<uint,int> ();
 
+            Selection.MaxIndex = Count - 1;
+
 			if (Changed != null)
 				Changed (this);
 			
@@ -378,5 +385,9 @@ namespace FSpot {
 		{
 			ItemsChanged (this, new BrowsableEventArgs (indexes, changes));
 		}
+
+        public PhotoSelection Selection {
+            get; protected set;
+        }
 	}
 }



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