[gnome-db] Some bugs to libgda and libgnomedb (1.2)
- From: "ALVAROPG telefonica net" <ALVAROPG telefonica net>
- To: gnome-db-list gnome org
- Subject: [gnome-db] Some bugs to libgda and libgnomedb (1.2)
- Date: Tue, 01 Feb 2005 16:54:39 +0100
Hi all,
Working with the GnomeDbGrid, I have found some bugs, when a new row
is inserted, GdaDataModel emits the "row_inserted" signal, but
GdaDataModel is a "interface", implemented by GdaDataModelArray, for
example, and this array model emits the signal too. Then the GnomeDbGrid
show 2 new rows.
And When a row is removed, the GdaDataModelArray don't renumber the
rows, like GnomeDbGrid with the DataModelInfo list.
I attach the patches. I'm working with the 1.2 release, the HEAD
sources don't compile.
buff, sorry for my english.
regards, apg
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgda/ChangeLog,v
retrieving revision 1.723.2.10
diff -u -r1.723.2.10 ChangeLog
--- ChangeLog 26 Jan 2005 03:17:08 -0000 1.723.2.10
+++ ChangeLog 1 Feb 2005 15:43:57 -0000
@@ -1,3 +1,11 @@
+2005-02-1 Álvaro Peña <alvaropg telefonica net>
+
+ * libgda/gda-data-model.c: Removed the signals emits
+ that must to emit the implementations, not this
+ "interface".
+ * libgda/gda-data-model-array.c: When a row is removed,
+ the following rows must to be renumber.
+
2005-01-25 Bas Driessen <bas driessen xobas com>
* providers/postgres/gda-postgres-recordset.c:
Index: libgda/gda-data-model.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-data-model.c,v
retrieving revision 1.48
diff -u -r1.48 gda-data-model.c
--- libgda/gda-data-model.c 25 Sep 2004 14:02:12 -0000 1.48
+++ libgda/gda-data-model.c 1 Feb 2005 15:43:58 -0000
@@ -671,7 +671,6 @@
g_return_val_if_fail (CLASS (model)->append_row != NULL, NULL);
row = CLASS (model)->append_row (model, values);
- gda_data_model_row_inserted (model, gda_row_get_number ((GdaRow *) row));
return row;
}
@@ -695,10 +694,6 @@
g_return_val_if_fail (CLASS (model)->remove_row != NULL, FALSE);
result = CLASS (model)->remove_row (model, row);
- if (result) {
- gda_data_model_row_removed (model, gda_row_get_number ((GdaRow *) row));
- }
-
return result;
}
@@ -722,9 +717,6 @@
g_return_val_if_fail (CLASS (model)->update_row != NULL, FALSE);
result = CLASS (model)->update_row (model, row);
- if (result) {
- gda_data_model_row_updated (model, gda_row_get_number ((GdaRow *) row));
- }
return result;
}
@@ -749,7 +741,6 @@
g_return_val_if_fail (attrs != NULL, FALSE);
result = CLASS (model)->append_column (model, attrs);
-
return result;
}
@@ -772,7 +763,6 @@
g_return_val_if_fail (CLASS (model)->remove_column != NULL, FALSE);
result = CLASS (model)->remove_column (model, col);
-
return result;
}
@@ -797,7 +787,6 @@
g_return_val_if_fail (attrs != NULL, FALSE);
result = CLASS (model)->update_column (model, col, attrs);
-
return result;
}
Index: libgda/gda-data-model-array.c
===================================================================
RCS file: /cvs/gnome/libgda/libgda/gda-data-model-array.c,v
retrieving revision 1.22
diff -u -r1.22 gda-data-model-array.c
--- libgda/gda-data-model-array.c 25 Sep 2004 14:02:12 -0000 1.22
+++ libgda/gda-data-model-array.c 1 Feb 2005 15:43:58 -0000
@@ -131,15 +131,35 @@
static gboolean
gda_data_model_array_remove_row (GdaDataModel *model, const GdaRow *row)
{
+ gint i, rownum, cols;
+ GdaValue *value;
+
g_return_val_if_fail (GDA_IS_DATA_MODEL_ARRAY (model), FALSE);
g_return_val_if_fail (row != NULL, FALSE);
- if (g_ptr_array_remove (GDA_DATA_MODEL_ARRAY (model)->priv->rows, (gpointer) row)) {
- gda_data_model_row_removed (model, gda_row_get_number (row));
- return TRUE;
+ cols = GDA_DATA_MODEL_ARRAY (model)->priv->number_of_columns;
+
+ for (i = 0; i < cols; i++) {
+ value = (GdaValue *) gda_row_get_value ((GdaRow *) row, i);
+ gda_value_set_string (value, "NULL");
}
+
+ /* renumber following rows */
+ rownum = gda_row_get_number ((GdaRow *) row);
+ for (i = (rownum + 1); i < GDA_DATA_MODEL_ARRAY (model)->priv->rows->len; i++)
+ gda_row_set_number ((GdaRow *) gda_data_model_get_row (GDA_DATA_MODEL (model), i), (i-1));
+
+ /* tag the row as being removed */
+ gda_row_set_id ((GdaRow *) row, "R");
+ gda_row_set_number ((GdaRow *) row, -1);
+
+ /* remove entry from the array */
+ g_ptr_array_remove (GDA_DATA_MODEL_ARRAY (model)->priv->rows, (gpointer) row);
+
+ /* emit updated signals */
+ gda_data_model_row_removed (model, rownum);
- return FALSE;
+ return TRUE;
}
static gboolean
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/libgnomedb/ChangeLog,v
retrieving revision 1.335.2.2
diff -u -r1.335.2.2 ChangeLog
--- ChangeLog 28 Dec 2004 13:47:27 -0000 1.335.2.2
+++ ChangeLog 1 Feb 2005 15:48:10 -0000
@@ -1,3 +1,9 @@
+2005-02-01 Álvaro Peña <alvaropg telefonica net>
+
+ * libgnomedb/gnome-db-model.c: When a row is removed
+ must to be removed from the list store, and the
+ DataModelInfo->row must to be renumberer.
+
2004-12-28 Rodrigo Moya <rodrigo gnome-db org>
Released 1.2.0.
Index: libgnomedb/gnome-db-model.c
===================================================================
RCS file: /cvs/gnome/libgnomedb/libgnomedb/gnome-db-model.c,v
retrieving revision 1.30
diff -u -r1.30 gnome-db-model.c
--- libgnomedb/gnome-db-model.c 7 Jan 2004 23:34:41 -0000 1.30
+++ libgnomedb/gnome-db-model.c 1 Feb 2005 15:48:10 -0000
@@ -217,7 +217,7 @@
GtkTreeIter iter;
GtkTreePath *path;
GtkTreeView *tree_view = user_data;
-
+
gtk_tree_model_iter_nth_child (gtk_tree_view_get_model (tree_view), &iter, NULL, row);
path = gtk_tree_path_new ();
gtk_tree_path_append_index (path, row);
@@ -229,14 +229,36 @@
static void
model_row_removed_cb (GdaDataModel *model, gint row, gpointer user_data)
{
- GtkTreePath *path;
- GtkTreeView *tree_view = user_data;
- path = gtk_tree_path_new ();
- gtk_tree_path_append_index (path, row);
- gtk_tree_model_row_deleted (gtk_tree_view_get_model (tree_view), path);
+ DataModelInfo *info = NULL;
+ gint i;
+ gint row_count;
+ gint rows_number;
+ GtkTreeIter iter;
+ GtkTreeView *tree_view = user_data;
- gtk_tree_path_free (path);
+
+ gtk_tree_model_iter_nth_child (gtk_tree_view_get_model (tree_view),
+ &iter,
+ NULL, row);
+ gtk_tree_store_remove (gtk_tree_view_get_model (tree_view), &iter);
+
+ row_count = gda_data_model_get_n_rows (model);
+ for (i = 0; i < row_count; i++) {
+ gtk_tree_model_iter_nth_child (gtk_tree_view_get_model (tree_view),
+ &iter,
+ NULL, i);
+ gtk_tree_model_get (gtk_tree_view_get_model (tree_view), &iter,
+ 0, &info,
+ -1);
+ if (info->row > row) {
+ info->row--;
+ gtk_tree_store_set (gtk_tree_view_get_model (tree_view), &iter,
+ 0, info,
+ -1);
+ }
+
+ }
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]