Re: [gnome-db] db grid ordering



On Sun, 2003-12-07 at 15:23, Rodrigo Moya wrote:
> I think you should just use the gda_value_compare function to compare
> the 2 values. gnome-db-model.c should just call that function. 
Of course! I missed that function.

Works excellent now.

note: I've also removed the NULL conditions as they are handled by
compare()

-- 
Marius Andreiana
Galuna - Solutii Linux in Romania
http://www.galuna.ro
Index: libgnomedb/gnome-db-model.c
===================================================================
RCS file: /cvs/gnome/libgnomedb/libgnomedb/gnome-db-model.c,v
retrieving revision 1.27
diff -u -r1.27 gnome-db-model.c
--- libgnomedb/gnome-db-model.c	10 Mar 2003 00:16:57 -0000	1.27
+++ libgnomedb/gnome-db-model.c	7 Dec 2003 14:10:51 -0000
@@ -85,7 +85,6 @@
 {
 	DataModelInfo *infoa, *infob;
 	const GdaValue *valuea, *valueb;
-	gint retval = 1;
 
 	gtk_tree_model_get (model, itera, 0, &infoa, -1);
 	gtk_tree_model_get (model, iterb, 0, &infob, -1);
@@ -98,39 +97,8 @@
 	valueb = gda_data_model_get_value_at (infob->model,
 					      GPOINTER_TO_INT (user_data),
 					      infob->row);
-	if (!valuea || !valueb)
-		return 0;
-
-	/* compare values */
-	if (gda_value_isa ((GdaValue *) valuea, GDA_VALUE_TYPE_NULL) &&
-	    gda_value_isa ((GdaValue *) valueb, GDA_VALUE_TYPE_NULL))
-		retval = 0;
-	else if (gda_value_isa ((GdaValue *) valuea, GDA_VALUE_TYPE_BIGINT) &&
-		 gda_value_isa ((GdaValue *) valueb, GDA_VALUE_TYPE_BIGINT)) {
-		if (gda_value_get_bigint ((GdaValue *) valuea) >
-		    gda_value_get_bigint ((GdaValue *) valueb))
-			retval = -1;
-	}
-	else {
-		gchar *stra, *strb;
-
-		/* data types don't match, so use strings to sort */
-		stra = gda_value_stringify ((GdaValue *) valuea);
-		strb = gda_value_stringify ((GdaValue *) valueb);
-		if (!stra && !strb)
-			retval = 0;
-		else if (!stra)
-			retval = 1;
-		else if (!strb)
-			retval = -1;
-		else
-			retval = strcmp (stra, strb);
-
-		g_free (stra);
-		g_free (strb);
-	}
-
-	return retval;
+	
+	return gda_value_compare( valuea, valueb );
 }
 
 /*


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