示例#1
0
/**
 * gda_data_access_wrapper_set_mapping:
 * @wrapper: a #GdaDataAccessWrapper object
 * @mapping: (allow-none) (array length=mapping_size): an array of #gint which represents the mapping between @wrapper's columns
 * and the columns of the wrapped data model
 * @mapping_size: the size of @mapping.
 *
 * @wrapper will report as many columns as @mapping_size, and for each value at position 'i' in @mapping,
 * @wrapper will report the 'i'th column, mapped to the wrapped data model column at position mapping[i].
 * For example if mapping is {3, 4, 0}, then @wrapper will report 3 columns, respectively mapped to the 4th,
 * 5th and 1st columns of the wrapped data model (as column numbers start at 0).
 *
 * If @mapping is %NULL, then no mapping is done and @wrapper's columns will be the same as the wrapped
 * data model.
 *
 * If a column in @mapping does not exist in the wrapped data model, then it is simply ignored (no error
 * reported).
 *
 * Please note that if @wrapper has already been used and if the wrapped data model offers a cursor forward
 * access mode, then this method will return %FALSE and no action will be done.
 *
 * If the mapping is applied, then any existing iterator will be invalid, and @wrapper is reset as if it
 * had just been created.
 *
 * Returns: %TRUE if the mapping actually changed
 *
 * Since: 5.2
 */
gboolean
gda_data_access_wrapper_set_mapping (GdaDataAccessWrapper *wrapper, const gint *mapping, gint mapping_size)
{
	g_return_val_if_fail (GDA_IS_DATA_ACCESS_WRAPPER (wrapper), FALSE);

	if ((! (wrapper->priv->model_access_flags & GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD)) &&
	    (wrapper->priv->iter_row >= 0)) {
		/* error */
		return FALSE;
	}

	clear_internal_state (wrapper);

	if (mapping) {
		/* define mapping */
		wrapper->priv->rows_mapping = g_new (gint, mapping_size);
		memcpy (wrapper->priv->rows_mapping, mapping, mapping_size * sizeof (gint));
		wrapper->priv->nb_cols = mapping_size;
	}
	else {
		if (wrapper->priv->rows_mapping) {
			g_free (wrapper->priv->rows_mapping);
			wrapper->priv->rows_mapping = NULL;
		}
	}

	compute_columns (wrapper);
	gda_data_model_reset ((GdaDataModel*) wrapper);

	return TRUE;
}
示例#2
0
static void
action_executed_holder_changed_cb (G_GNUC_UNUSED GdaSet *params, G_GNUC_UNUSED GdaHolder *holder,
				   ActionExecutedData *aed)
{
	if (! aed->formgrid->priv->autoupdate || ! aed->formgrid->priv->autoupdate_possible)
		return;

	GError *error = NULL;
	gda_data_model_freeze (aed->model);
	if (!t_connection_rerun_select (aed->tcnc, aed->model, &error)) {
		GtkWidget *toplevel;
		toplevel = gtk_widget_get_toplevel (GTK_WIDGET (aed->formgrid));
		ui_show_error (GTK_WINDOW (toplevel),
			       _("Error executing query:\n%s"), error->message ? error->message : _("No detail"));
		g_clear_error (&error);
		gda_data_model_thaw (aed->model);
	}
	else {
		gda_data_model_thaw (aed->model);
		gda_data_model_reset (aed->model);
	}
}
示例#3
0
static void
model_reset_cb (G_GNUC_UNUSED GdaDataModel *mod, GdaDataAccessWrapper *model)
{
	gda_data_model_reset ((GdaDataModel*) model);
}