f-spot r3662 - in trunk/src: . Core Jobs Widgets



Author: sdelcroix
Date: Mon Feb 11 12:40:10 2008
New Revision: 3662
URL: http://svn.gnome.org/viewvc/f-spot?rev=3662&view=rev

Log:
clean the remaining unrated bits

Modified:
   trunk/src/Core/Photo.cs
   trunk/src/Jobs/SyncMetadataJob.cs
   trunk/src/PhotoStore.cs
   trunk/src/PhotoView.cs
   trunk/src/Updater.cs
   trunk/src/Widgets/IconView.cs

Modified: trunk/src/Core/Photo.cs
==============================================================================
--- trunk/src/Core/Photo.cs	(original)
+++ trunk/src/Core/Photo.cs	Mon Feb 11 12:40:10 2008
@@ -21,12 +21,6 @@
 
 namespace FSpot
 {
-	public class NotRatedException : System.ApplicationException
-	{
-		public NotRatedException (string message) : base (message)
-		{}
-	}
-
 	public class Photo : DbItem, IComparable, IBrowsableItem {
 		// IComparable 
 		public int CompareTo (object obj) {
@@ -173,28 +167,14 @@
 		}
 	
 		private uint rating;
-		private bool rated = false;
 		public uint Rating {
-			get {
-				if (!rated)
-					throw new NotRatedException ("This photo is not rated yet");
-				else
-					return rating;
-			}
+			get { return rating; }
 			set {
-				if (value >= 0 && value <= 5) {
+				if (value >= 0 && value <= 5)
 					rating = value;
-					rated = true;
-				} else
-					rated = false;
 			}
 		}
 	
-		public void RemoveRating ()
-		{
-			rated = false;
-		}
-	
 		// Version management
 		public const int OriginalVersionId = 1;
 		private uint highest_version_id;
@@ -569,7 +549,7 @@
 			time = DbUtils.DateTimeFromUnixTime (unix_time);
 	
 			description = String.Empty;
-			rated = false;
+			rating = 0;
 	
 			// Note that the original version is never stored in the photo_versions table in the
 			// database.

Modified: trunk/src/Jobs/SyncMetadataJob.cs
==============================================================================
--- trunk/src/Jobs/SyncMetadataJob.cs	(original)
+++ trunk/src/Jobs/SyncMetadataJob.cs	Mon Feb 11 12:40:10 2008
@@ -82,14 +82,10 @@
 				names [i] = tags [i].Name;
 			
 			xmp.Store.Update ("dc:subject", "rdf:Bag", names);
-			try { 
 				xmp.Store.Update ("xmp:Rating", (item as Photo).Rating.ToString());
 	// FIXME - Should we also store/overwrite the Urgency field?
 	//			uint urgency_value = (item as Photo).Rating + 1; // Urgency valid values 1 - 8
 	//			xmp.Store.Update ("photoshop:Urgency", urgency_value.ToString());
-			} catch (NotRatedException) {
-				xmp.Store.Delete ("xmp:Rating");
-			}
 			xmp.Dump ();
 	
 			return xmp;

Modified: trunk/src/PhotoStore.cs
==============================================================================
--- trunk/src/PhotoStore.cs	(original)
+++ trunk/src/PhotoStore.cs	Mon Feb 11 12:40:10 2008
@@ -177,7 +177,7 @@
 	 			"description", description,
 				"roll_id", roll_id,
 	 			"default_version_id", Photo.OriginalVersionId,
-	 			"rating", null));
+				"rating", "0"));
 	
 			photo = new Photo (id, unix_time, new_uri);
 			AddToCache (photo);
@@ -318,10 +318,7 @@
 			photo.Description = reader[2].ToString ();
 			photo.RollId = Convert.ToUInt32 (reader[3]);
 			photo.DefaultVersionId = Convert.ToUInt32 (reader[4]);
-			if (reader [5] != null)
-				photo.Rating = Convert.ToUInt32 (reader [5]);
-			else
-				photo.RemoveRating();
+			photo.Rating = Convert.ToUInt32 (reader [5]);
 			AddToCache (photo);
 		}
 		reader.Close();
@@ -356,10 +353,7 @@
 			photo.Description = reader[2].ToString ();
 			photo.RollId = Convert.ToUInt32 (reader[3]);
 			photo.DefaultVersionId = Convert.ToUInt32 (reader[4]);
-			if (reader [5] != null)
-				photo.Rating = Convert.ToUInt32 (reader [5]);
-			else
-				photo.RemoveRating();
+			photo.Rating = Convert.ToUInt32 (reader [5]);
 		}
 	        reader.Close();
 
@@ -442,13 +436,6 @@
 	private void Update (Photo photo) {
 		// Update photo.
 
-		uint rate = 0;
-		bool rated = false;
-		try {
-			rate = photo.Rating;
-			rated = true;
-		} catch {
-		}
 		Database.ExecuteNonQuery (new DbCommand (
 			"UPDATE photos SET description = :description, " + 
 			"default_version_id = :default_version_id, " + 
@@ -460,7 +447,7 @@
 			"default_version_id", photo.DefaultVersionId,
 			"time", DbUtils.UnixTimeFromDateTime (photo.Time),
 			"uri", photo.VersionUri (Photo.OriginalVersionId).ToString (),
-			"rating", (rated ? String.Format ("{0}", rate) : null),
+			"rating", String.Format ("{0}", photo.Rating),
 			"id", photo.Id));
 
 		// Update tags.
@@ -564,10 +551,7 @@
 				photo.Description = reader[3].ToString ();
 				photo.RollId = Convert.ToUInt32 (reader[4]);
 				photo.DefaultVersionId = Convert.ToUInt32 (reader[5]);
-				if (reader [6] != null)
-					photo.Rating = Convert.ToUInt32 (reader [6]);
-				else
-					photo.RemoveRating ();
+				photo.Rating = Convert.ToUInt32 (reader [6]);
 				
 				version_list.Add (photo);
 			}

Modified: trunk/src/PhotoView.cs
==============================================================================
--- trunk/src/PhotoView.cs	(original)
+++ trunk/src/PhotoView.cs	Mon Feb 11 12:40:10 2008
@@ -203,11 +203,7 @@
 	{
 		rating.Changed -= HandleRatingChanged;
 		if (Item.IsValid)
-			try {
-				rating.Value = (int)Item.Current.Rating;
-			} catch (FSpot.NotRatedException) {
-				rating.Value = -1;
-			}
+			rating.Value = (int)Item.Current.Rating;
 		rating.Changed += HandleRatingChanged;
 	}
 
@@ -418,10 +414,7 @@
 		if (!Item.IsValid)
 			return;
 
-		if ((o as Widgets.Rating).Value < 0)
-			((Photo)Item.Current).RemoveRating();
-		else
-			((Photo)Item.Current).Rating = (uint)(o as Widgets.Rating).Value;
+		((Photo)Item.Current).Rating = (uint)(o as Widgets.Rating).Value;
 
 		if (commit_delay.IsPending)
 			if (changed_photo == Item.Index)

Modified: trunk/src/Updater.cs
==============================================================================
--- trunk/src/Updater.cs	(original)
+++ trunk/src/Updater.cs	Mon Feb 11 12:40:10 2008
@@ -241,6 +241,11 @@
 			});
 
 			// Update to version 14.0
+			AddUpdate (new Version (14,0), delegate () {
+				Execute ("UPDATE photos SET rating = 0 WHERE rating IS NULL");
+			});
+
+			// Update to version 14.0
 			//AddUpdate (new Version (14,0),delegate () {
 			//	do update here
 			//});

Modified: trunk/src/Widgets/IconView.cs
==============================================================================
--- trunk/src/Widgets/IconView.cs	(original)
+++ trunk/src/Widgets/IconView.cs	Mon Feb 11 12:40:10 2008
@@ -884,11 +884,7 @@
 			Gdk.Rectangle layout_bounds = Gdk.Rectangle.Zero;
 			if (DisplayRatings) {
 				FSpot.Widgets.RatingSmall rating;
-				try {
-					rating = new FSpot.Widgets.RatingSmall ((int) photo.Rating, false);
-				} catch (NotRatedException) {
-					rating = new FSpot.Widgets.RatingSmall (-1, false);
-				}
+				rating = new FSpot.Widgets.RatingSmall ((int) photo.Rating, false);
 				if (region.Intersect (area, out region)) {
 				rating.DisplayPixbuf.RenderToDrawable (BinWindow, Style.WhiteGC,
 						0, 0, region.X, region.Y, -1, -1, RgbDither.None, region.X, region.Y);



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