[f-spot] order by uri too



commit a4b461de5c4307b6f1c41361b86ff11801df6d45
Author: Stephane Delcroix <stephane delcroix org>
Date:   Thu Jun 11 14:03:15 2009 +0200

    order by uri too
    
    the query are now sorted on time then on uri, allowing a correct order of shots of the same second, if the filenames are sequentials (for that second)
---
 src/Makefile.am         |    1 +
 src/PhotoQuery.cs       |   10 +++++++---
 src/PhotoStore.cs       |   10 +++++++---
 src/Query/OrderByUri.cs |   35 +++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index cf10222..8a2d2cb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,6 +42,7 @@ QUERY_CSDISTFILES =				\
 	$(srcdir)/Query/IQueryCondition.cs	\
 	$(srcdir)/Query/LogicalTerm.cs		\
 	$(srcdir)/Query/OrderByTime.cs		\
+	$(srcdir)/Query/OrderByUri.cs		\
 	$(srcdir)/Query/RatingRange.cs		\
 	$(srcdir)/Query/RollSet.cs		\
 	$(srcdir)/Query/UntaggedCondition.cs
diff --git a/src/PhotoQuery.cs b/src/PhotoQuery.cs
index e977f3b..1e45763 100644
--- a/src/PhotoQuery.cs
+++ b/src/PhotoQuery.cs
@@ -90,7 +90,7 @@ namespace FSpot {
 			foreach (IQueryCondition condition in conditions)
 				SetCondition (condition);
 
-			store.QueryToTemp (temp_table, (Tag [])null, null, Range, RollSet, RatingRange, OrderByTime);
+			store.QueryToTemp (temp_table, (Tag [])null, null, Range, RollSet, RatingRange, OrderByTime, OrderByUri);
 		}
 
 		public int Count {
@@ -236,6 +236,10 @@ namespace FSpot {
 			}
 		}
 
+		OrderByUri OrderByUri {
+			get { return new OrderByUri (OrderByTime.Asc);}
+		}
+
 		public bool TimeOrderAsc {
 			get { return OrderByTime.Asc; }
 			set {
@@ -248,9 +252,9 @@ namespace FSpot {
 		{
 			uint timer = Log.DebugTimerStart ();
 			if (untagged)
-				store.QueryToTemp (temp_table, new UntaggedCondition (), Range, RollSet, RatingRange, OrderByTime);
+				store.QueryToTemp (temp_table, new UntaggedCondition (), Range, RollSet, RatingRange, OrderByTime, OrderByUri);
 			else
-				store.QueryToTemp (temp_table, terms, extra_condition, Range, RollSet, RatingRange, OrderByTime);
+				store.QueryToTemp (temp_table, terms, extra_condition, Range, RollSet, RatingRange, OrderByTime, OrderByUri);
 
 			count = -1;
 			cache = new PhotoCache (store, temp_table);
diff --git a/src/PhotoStore.cs b/src/PhotoStore.cs
index 15a6a4d..c487066 100644
--- a/src/PhotoStore.cs
+++ b/src/PhotoStore.cs
@@ -954,9 +954,9 @@ public class PhotoStore : DbStore<Photo> {
 	}
 
 	[Obsolete ("drop this, use IQueryCondition correctly instead")]
-	public void QueryToTemp (string temp_table, Tag [] tags, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange, OrderByTime orderbytime)
+	public void QueryToTemp (string temp_table, Tag [] tags, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange, OrderByTime orderbytime, OrderByUri orderbyuri)
 	{
-		QueryToTemp (temp_table, FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, ratingrange, orderbytime);
+		QueryToTemp (temp_table, FSpot.OrTerm.FromTags(tags), extra_condition, range, importidrange, ratingrange, orderbytime, orderbyuri);
 	}
 
 	[Obsolete ("drop this, use IQueryCondition correctly instead")]
@@ -966,7 +966,7 @@ public class PhotoStore : DbStore<Photo> {
 	}
 
 	[Obsolete ("drop this, use IQueryCondition correctly instead")]
-	public void QueryToTemp (string temp_table, Term searchexpression, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange, OrderByTime orderbytime)
+	public void QueryToTemp (string temp_table, Term searchexpression, string extra_condition, DateRange range, RollSet importidrange, RatingRange ratingrange, OrderByTime orderbytime, OrderByUri orderbyuri)
 	{
 		bool hide = (extra_condition == null);
 
@@ -1033,6 +1033,10 @@ public class PhotoStore : DbStore<Photo> {
 		}
 		query_builder.Append (" ORDER BY ");
 		query_builder.Append (orderbytime.SqlClause ());
+
+		query_builder.Append (", ");
+		query_builder.Append (orderbyuri.SqlClause ());
+Console.WriteLine (query_builder.ToString ());
 		QueryToTemp (temp_table, query_builder.ToString ());
 	}
 
diff --git a/src/Query/OrderByUri.cs b/src/Query/OrderByUri.cs
new file mode 100644
index 0000000..88941c0
--- /dev/null
+++ b/src/Query/OrderByUri.cs
@@ -0,0 +1,35 @@
+/*
+ * FSpot.Query.OrderByUri.cs
+ *
+ * Author(s):
+ *	Stephane Delcroix <stephane delcroix org>
+ *
+ * This is free software. See COPYING for details.
+ *
+ */
+
+using System;
+using FSpot.Utils;
+
+namespace FSpot.Query {
+	public class OrderByUri : IQueryCondition, IOrderCondition
+	{
+		public static OrderByUri OrderByFilenameAsc = new OrderByUri (true);
+		public static OrderByUri OrderByFilenameDesc = new OrderByUri (false);
+
+		bool asc;
+		public bool Asc {
+			get { return asc; }
+		}
+
+		public OrderByUri (bool asc)
+		{
+			this.asc = asc;
+		}
+
+		public string SqlClause ()
+		{
+			return String.Format (" uri {0}", asc ? "ASC" : "DESC");
+		}
+	}
+}



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