Reparado el bug por el que no aparecían todos los registros del modelo cuando era 'nullable' el campo
This commit is contained in:
Alejandro T. Colombini Gómez 2014-10-16 12:31:50 +02:00
parent 1a32fc4250
commit 77f182fa03
5 changed files with 30 additions and 28 deletions

View File

@ -18,7 +18,8 @@
#include "db-model-holder.h"
#include "db-iterator.h"
#define GET_MODEL(self) DB_MODEL_HOLDER_GET_INTERFACE (self)->get_model (DB_MODEL_HOLDER (self))
#define GET_MODEL(self) (DB_MODEL_HOLDER_GET_INTERFACE (self)->get_model (DB_MODEL_HOLDER (self)))
#define GET_ITER(self, iter_return) (DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, iter_return))
/**
* SECTION: db-iterator
@ -61,7 +62,7 @@ static void db_iterator_set_iter (DbIterator * self, DbIter * iter)
static gboolean db_iterator_has_row_selected (DbIterator * self)
{
DbIter * iter;
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &iter);
GET_ITER (self, &iter);
if (iter)
return TRUE;
@ -133,7 +134,7 @@ gboolean db_iterator_get_iter (DbIterator * self, DbIter ** iter)
g_return_val_if_fail (DB_IS_ITERATOR (self), FALSE);
ok = DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
ok = GET_ITER (self, &self_iter);
*iter = db_iter_copy (self_iter);
return ok;
@ -349,7 +350,7 @@ gboolean db_iterator_move_previous (DbIterator * self)
DbIter * self_iter;
gboolean move = FALSE;
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
if (self_iter)
{
@ -382,7 +383,7 @@ gboolean db_iterator_move_next (DbIterator * self)
DbIter * self_iter;
gboolean move = FALSE;
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
if (self_iter)
{
@ -439,10 +440,9 @@ void db_iterator_insert (DbIterator * self)
DbIter iter, * self_iter;
DbModel * model;
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
model = GET_MODEL (self);
if (self_iter && db_iterator_get_mode (self) != DB_ITERATOR_MODE_ON_DEMAND)
if (GET_ITER (self, &self_iter) && db_iterator_get_mode (self) != DB_ITERATOR_MODE_ON_DEMAND)
{
if (db_model_get_row_operations (model, self_iter) == DB_MODEL_ROW_OP_INSERT)
return;
@ -529,7 +529,7 @@ const GValue * db_iterator_get_value (DbIterator * self, const gchar * column_na
g_return_val_if_fail (DB_IS_ITERATOR (self), NULL);
model = GET_MODEL (self);
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
if (self_iter)
{
@ -561,7 +561,7 @@ gboolean db_iterator_set_value (DbIterator * self, const gchar * column_name, co
g_return_val_if_fail (DB_IS_ITERATOR (self), NULL);
model = GET_MODEL (self);
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
if (db_iterator_has_row_selected (self))
{
@ -590,7 +590,7 @@ const GValue * db_iterator_get_value_by_index (DbIterator * self, gint column)
DbIter * self_iter;
DbModel * model;
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
model = GET_MODEL (self);
if (self_iter)
@ -619,7 +619,7 @@ gboolean db_iterator_set_value_by_index (DbIterator * self, gint column, const G
DbIter * self_iter;
DbModel * model = GET_MODEL (self);
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
return db_model_set_value (model, self_iter, column, value, err);
}
@ -741,7 +741,7 @@ DbModelRowOp db_iterator_get_pending_operations (DbIterator * self)
DbIter * self_iter;
DbModel * model;
DB_ITERATOR_GET_INTERFACE (self)->get_iter (self, &self_iter);
GET_ITER (self, &self_iter);
model = GET_MODEL (self);
if (model && self_iter)
@ -864,6 +864,10 @@ void db_iterator_set_string (DbIterator * self, const gchar * column_name, const
db_iterator_take_value (self, column_name, gvn_value_new_string (value));
}
/**
* db_iterator_get_boxed:
* Return value: (transfer none):
*/
gpointer db_iterator_get_boxed (DbIterator * self, const gchar * column_name)
{
g_return_val_if_fail (DB_IS_ITERATOR (self), NULL);

View File

@ -1,3 +1 @@
Vn cheader_filename="vn/vn.h"
Form.@get type="unowned GLib.Object"

View File

@ -182,6 +182,8 @@ static void vn_column_combo_set_null (VnColumnCombo * self, gboolean null)
vn_list_model_use_null_row (VN_LIST_MODEL (self->tree), null);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++ DbModelHolder implementation
static void vn_column_combo_model_changed (VnColumnCombo * self)
{
if (self->model)
@ -206,8 +208,6 @@ static void vn_column_combo_on_status_changed (DbModel * model,
g_object_set (VN_COLUMN (self)->cell, "model", NULL, NULL);
}
//+++++++++++++++++++++++++++++++++++++++++++++++++ DbModelHolder implementation
static void vn_column_combo_set_model (VnColumnCombo * self, DbModel * model)
{
g_return_if_fail (!model || DB_IS_MODEL (model));

View File

@ -91,12 +91,12 @@ static void vn_combo_on_status_changed (DbModel * model, DbModelStatus status, V
{
if (status == DB_MODEL_STATUS_READY)
{
vn_list_model_use_null_row (VN_LIST_MODEL (self->tree),
vn_field_get_null (VN_FIELD (self)));
gtk_combo_box_set_model (self->combo, self->tree);
self->tree_set = TRUE;
vn_combo_on_model_ready (self, gvn_param_get_value (GVN_PARAM (self)));
vn_list_model_use_null_row (VN_LIST_MODEL (self->tree),
vn_field_get_null (VN_FIELD (self)));
}
else
{

View File

@ -318,18 +318,18 @@ static void vn_list_model_get_value (GtkTreeModel * self, GtkTreeIter * iter,
static gboolean vn_list_model_iter_next (GtkTreeModel * self, GtkTreeIter * iter)
{
DbIter dbiter;
gboolean ret_val;
gboolean ok;
if (iter->user_data != self)
{
gtk_tree_iter_to_db_iter (iter, &dbiter);
ret_val = db_model_iter_next (VN_LIST_MODEL (self)->model, &dbiter);
ok = db_model_iter_next (VN_LIST_MODEL (self)->model, &dbiter);
}
else
ret_val = db_model_get_iter_first (VN_LIST_MODEL (self)->model, &dbiter);
ok = db_model_get_iter_first (VN_LIST_MODEL (self)->model, &dbiter);
gtk_tree_iter_from_db_iter (iter, &dbiter);
return ret_val;
return ok;
}
static gboolean vn_list_model_iter_previous (GtkTreeModel * self, GtkTreeIter * iter)
@ -362,23 +362,23 @@ static gboolean vn_list_model_iter_children (GtkTreeModel * self, GtkTreeIter *
{
if (parent == NULL)
{
gboolean ret_val;
gboolean ok;
if (!VN_LIST_MODEL (self)->null_row)
{
DbIter dbiter;
ret_val = db_model_get_iter_first (VN_LIST_MODEL (self)->model, &dbiter);
ok = db_model_get_iter_first (VN_LIST_MODEL (self)->model, &dbiter);
if (ret_val)
if (ok)
gtk_tree_iter_from_db_iter (iter, &dbiter);
}
else
{
iter->user_data = self;
ret_val = TRUE;
ok = TRUE;
}
return ret_val;
return ok;
}
return FALSE;