Gda.DataProxy

g GObject.GInterface GObject.GInterface Gda.DataModel Gda.DataModel GObject.GInterface->Gda.DataModel GObject.Object GObject.Object Gda.DataProxy Gda.DataProxy GObject.Object->Gda.DataProxy Gda.DataModel->Gda.DataProxy

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gda.DataModel (43)

Structs:

GObject.ObjectClass (5)

class

error_quark ()

class

new (model)

class

new_with_data_model (model)

alter_value_attributes (proxy_row, col, alter_flags)

apply_all_changes ()

apply_row_changes (proxy_row)

cancel_all_changes ()

cancel_row_changes (proxy_row, col)

delete (proxy_row)

get_filter_expr ()

get_filtered_n_rows ()

get_n_modified_rows ()

get_n_new_rows ()

get_proxied_model ()

get_proxied_model_n_cols ()

get_proxied_model_n_rows ()

get_proxied_model_row (proxy_row)

get_sample_end ()

get_sample_size ()

get_sample_start ()

get_value_attributes (proxy_row, col)

get_values (proxy_row, cols_index)

has_changed ()

is_read_only ()

row_has_changed (proxy_row)

row_is_deleted (proxy_row)

row_is_inserted (proxy_row)

set_filter_expr (filter_expr)

set_ordering_column (col)

set_sample_size (sample_size)

set_sample_start (sample_start)

undelete (proxy_row)

Virtual Methods

Inherited:

GObject.Object (7), Gda.DataModel (27)

do_filter_changed ()

do_row_changes_applied (row, proxied_row)

do_row_delete_changed (row, to_be_deleted)

do_sample_changed (sample_start, sample_end)

do_sample_size_changed (sample_size)

do_validate_row_changes (row, proxied_row)

Properties

Name

Type

Flags

Short Description

cache-changes

bool

r/w

set to True to keep track of changes even when the proxied data model is changed

defer-sync

bool

r/w

Tells if changes to the sample of rows displayed is done in background in several steps or if it’s done in one step.

model

Gda.DataModel

r/w/c

Proxied data model

prepend-null-entry

bool

r/w

Tells if a row composed of None values is inserted as the proxy’s first row

sample-size

int

r/w/c

Number of rows which the proxy will contain at any time, like a sliding window on the proxied data model

Signals

Inherited:

GObject.Object (1), Gda.DataModel (6)

Name

Short Description

filter-changed

Gets emitted when proxy's filter has been changed

row-changes-applied

Gets emitted when proxy has committed a row change to the proxied data model.

row-delete-changed

Gets emitted whenever a row has been marked to be deleted, or has been unmarked to be deleted

sample-changed

Gets emitted whenever proxy's sample size has been changed.

sample-size-changed

Gets emitted whenever proxy's sample size has been changed

validate-row-changes

Gets emitted when proxy is about to commit a row change to the proxied data model.

Fields

Inherited:

GObject.Object (1), Gda.DataModel (6)

Name

Type

Access

Description

object

GObject.Object

r

Class Details

class Gda.DataProxy(**kwargs)
Bases:

GObject.Object, Gda.DataModel

Abstract:

No

Structure:

Gda.DataProxyClass

classmethod error_quark()
Return type:

int

classmethod new(model)
Parameters:

model (Gda.DataModel) – Data model to be proxied

Returns:

a new Gda.DataProxy object

Return type:

GObject.Object

Creates a new proxy for model. For bindings use gda_data_proxy_new_with_data_model.

classmethod new_with_data_model(model)
Parameters:

model (Gda.DataModel) – Data model to be proxied

Returns:

a new Gda.DataProxy object

Return type:

Gda.DataProxy

Creates a new proxy for model. This is the preferred method to create Gda.DataProxy objects by bindings.

New in version 5.2.0.

alter_value_attributes(proxy_row, col, alter_flags)
Parameters:
  • proxy_row (int) – A proxy row number

  • col (int) – a valid column number

  • alter_flags (Gda.ValueAttribute) – flags to alter the attributes

Alters the attributes of the value stored at (proxy_row, col) in self. the alter_flags can only contain the Gda.ValueAttribute.IS_NULL, Gda.ValueAttribute.IS_DEFAULT and Gda.ValueAttribute.IS_UNCHANGED flags (other flags are ignored).

apply_all_changes()
Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Apply all the changes stored in the proxy to the proxied data model. The changes are done row after row, and if an error occurs, then it is possible that not all the changes to all the rows have been applied.

apply_row_changes(proxy_row)
Parameters:

proxy_row (int) – the row number to commit

Raises:

GLib.Error

Returns:

True if no error occurred.

Return type:

bool

Commits the modified data in the proxy back into the Gda.DataModel.

cancel_all_changes()
Returns:

True if no error occurred

Return type:

bool

Cancel all the changes stored in the proxy (the self will be reset to its state as it was just after creation). Note that if there are some cached changes (i.e. not applied to the current proxied data model), then these cached changes are not cleared (set the “cache-changes” property to False for this).

cancel_row_changes(proxy_row, col)
Parameters:
  • proxy_row (int) – the row to cancel changes

  • col (int) – the column to cancel changes, or less than 0 to cancel any change on the row row

Resets data at the corresponding row and column. If proxy_row corresponds to a new row, then that new row is deleted from self.

delete(proxy_row)
Parameters:

proxy_row (int) – A proxy row number

Marks the row proxy_row to be deleted

get_filter_expr()
Returns:

the current filter expression or None if no filter has been set

Return type:

str

Get the current filter expression used by self.

get_filtered_n_rows()
Returns:

the number of filtered rows in self, or -1 if no filter has been applied

Return type:

int

Get the total number of filtered rows in self if a filter has been applied. As new rows (rows added to the proxy and not yet added to the proxied data model) and rows to remove (rows marked for removal but not yet removed from the proxied data model) are also filtered, the returned number also contains references to new rows and rows to be removed.

get_n_modified_rows()
Returns:

the number of modified rows

Return type:

int

Get the number of rows which have been modified in the proxy (the sum of rows existing in the proxied data model which have been modified, and new rows).

get_n_new_rows()
Returns:

the number of new rows

Return type:

int

Get the number of rows which have been added to self and which are not part of the proxied data model.

get_proxied_model()
Returns:

the proxied data model

Return type:

Gda.DataModel

Fetch the Gda.DataModel which self does proxy

get_proxied_model_n_cols()
Returns:

the number of columns, or -1 if an error occurred

Return type:

int

Get the number of columns in the proxied data model

get_proxied_model_n_rows()
Returns:

the number of rows, or -1 if the number of rows is not known

Return type:

int

Get the number of rows in the proxied data model

get_proxied_model_row(proxy_row)
Parameters:

proxy_row (int) – A proxy row number

Returns:

the proxied model’s row, or -1 if self row which only exists self

Return type:

int

Get the self's proxied model row corresponding to proxy_row

get_sample_end()
Returns:

the number of the last proxied model’s row.

Return type:

int

Get the number of the last row to be available in self (in reference to the proxied data model)

get_sample_size()
Returns:

the chunk (or sample) size, or 0 if chunking is disabled.

Return type:

int

Get the size of each chunk of data displayed at a time.

get_sample_start()
Returns:

the number of the first proxied model’s row.

Return type:

int

Get the number of the first row to be available in self (in reference to the proxied data model)

get_value_attributes(proxy_row, col)
Parameters:
  • proxy_row (int) – a proxy row

  • col (int) – a valid proxy column

Returns:

a Gda.ValueAttribute with the value’s attributes at given position

Return type:

Gda.ValueAttribute

Get the attributes of the value stored at (proxy_row, col) in self, which is an ORed value of Gda.ValueAttribute flags

get_values(proxy_row, cols_index)
Parameters:
  • proxy_row (int) – a proxy row

  • cols_index ([int]) – array containing the columns for which the values are requested

Returns:

a new list of values (the list must be freed, not the values), or None if an error occurred

Return type:

[GObject.Value]

Retrieve a whole list of values from the self data model. This function calls gda_data_proxy_get_value() for each column index specified in cols_index, and generates a GLib.SList on the way.

has_changed()
Returns:

True if there are some modifications in self

Return type:

bool

Tells if self contains any modifications not applied to the proxied data model.

is_read_only()
Returns:

True if the proxied data model is itself read-only

Return type:

bool

row_has_changed(proxy_row)
Parameters:

proxy_row (int) – A proxy row number

Returns:

True if the row has changed

Return type:

bool

Tells if the row number proxy_row has changed

row_is_deleted(proxy_row)
Parameters:

proxy_row (int) – A proxy row number

Returns:

True if the row is marked to be deleted

Return type:

bool

Tells if the row number proxy_row is marked to be deleted.

row_is_inserted(proxy_row)
Parameters:

proxy_row (int) – A proxy row number

Returns:

True if the row is an inserted row

Return type:

bool

Tells if the row number proxy_row is a row which has been inserted in self (and is thus not in the proxied data model).

set_filter_expr(filter_expr)
Parameters:

filter_expr (str or None) – an SQL based expression which will filter the contents of self, or None to remove any previous filter

Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Sets a filter among the rows presented by self. The filter is defined by a filter expression which can be any SQL valid expression using self's columns. For instance if self has the “id” and “name” columns, then a filter can be “length(name) < 5” to filter only the rows where the length of the name is strictly inferior to 5, or “id >= 1000 and id < 2000 order by name limit 50” to filter only the rows where the id is between 1000 and 2000, ordered by name and limited to 50 rows.

Note about column names: real column names can be used (double quoted if necessary), but columns can also be named “_&lt;column number&gt;” with column numbers starting at 1.

Note that any previous filter expression is replaced with the new filter_expr if no error occurs (if an error occurs, then any previous filter is left unchanged).

set_ordering_column(col)
Parameters:

col (int) – the column number to order from

Raises:

GLib.Error

Returns:

True if no error occurred

Return type:

bool

Orders by the col column

set_sample_size(sample_size)
Parameters:

sample_size (int) – the requested size of a chunk, or 0

Sets the size of each chunk of data to display: the maximum number of rows which can be “displayed” at a time (the maximum number of rows which self pretends to have). The default value is arbitrary 300 as it is big enough to be able to display quite a lot of data, but small enough to avoid too much data displayed at the same time.

Note: the rows which have been added but not yet committed will always be displayed regardless of the current chunk of data, and the modified rows which are not visible when the displayed chunk of data changes are still held as modified rows.

To remove the chunking of the data to display, simply pass sample_size the %0 value.

set_sample_start(sample_start)
Parameters:

sample_start (int) – the number of the first row to be displayed

Sets the number of the first row to be available in self (in reference to the proxied data model)

undelete(proxy_row)
Parameters:

proxy_row (int) – A proxy row number

Remove the “to be deleted” mark at the row proxy_row, if it existed.

do_filter_changed() virtual
do_row_changes_applied(row, proxied_row) virtual
Parameters:
  • row (int) –

  • proxied_row (int) –

do_row_delete_changed(row, to_be_deleted) virtual
Parameters:
  • row (int) –

  • to_be_deleted (bool) –

do_sample_changed(sample_start, sample_end) virtual
Parameters:
  • sample_start (int) –

  • sample_end (int) –

do_sample_size_changed(sample_size) virtual
Parameters:

sample_size (int) –

do_validate_row_changes(row, proxied_row) virtual
Parameters:
  • row (int) –

  • proxied_row (int) –

Return type:

GLib.Error

Signal Details

Gda.DataProxy.signals.filter_changed(data_proxy)
Signal Name:

filter-changed

Flags:

RUN_FIRST

Parameters:

data_proxy (Gda.DataProxy) – The object which received the signal

Gets emitted when proxy's filter has been changed

Gda.DataProxy.signals.row_changes_applied(data_proxy, row, proxied_row)
Signal Name:

row-changes-applied

Flags:

RUN_FIRST

Parameters:
  • data_proxy (Gda.DataProxy) – The object which received the signal

  • row (int) – the proxy’s row

  • proxied_row (int) – the proxied data model’s row

Gets emitted when proxy has committed a row change to the proxied data model.

Gda.DataProxy.signals.row_delete_changed(data_proxy, row, to_be_deleted)
Signal Name:

row-delete-changed

Flags:

RUN_FIRST

Parameters:
  • data_proxy (Gda.DataProxy) – The object which received the signal

  • row (int) – the concerned proxy's row

  • to_be_deleted (bool) – tells if the row is marked to be deleted

Gets emitted whenever a row has been marked to be deleted, or has been unmarked to be deleted

Gda.DataProxy.signals.sample_changed(data_proxy, sample_start, sample_end)
Signal Name:

sample-changed

Flags:

RUN_FIRST

Parameters:
  • data_proxy (Gda.DataProxy) – The object which received the signal

  • sample_start (int) – the first row of the sample

  • sample_end (int) – the last row of the sample

Gets emitted whenever proxy's sample size has been changed. sample_start and sample_end are in reference to the proxied data model.

Gda.DataProxy.signals.sample_size_changed(data_proxy, sample_size)
Signal Name:

sample-size-changed

Flags:

RUN_FIRST

Parameters:
  • data_proxy (Gda.DataProxy) – The object which received the signal

  • sample_size (int) – the new sample size

Gets emitted whenever proxy's sample size has been changed

Gda.DataProxy.signals.validate_row_changes(data_proxy, row, proxied_row)
Signal Name:

validate-row-changes

Flags:

RUN_LAST

Parameters:
  • data_proxy (Gda.DataProxy) – The object which received the signal

  • row (int) – the proxy’s row

  • proxied_row (int) – the proxied data model’s row

Returns:

a new GLib.Error if validation failed, or None

Return type:

GLib.Error

Gets emitted when proxy is about to commit a row change to the proxied data model. If any callback returns a non None value, then the change commit fails with the returned GLib.Error

Property Details

Gda.DataProxy.props.cache_changes
Name:

cache-changes

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Defines how changes kept in the data proxy are handled when the proxied data model is changed (using the “model” property). The default is to silently discard all the changes, but if this property is set to True, then the changes are cached.

If set to True, each cached change will be re-applied to a newly set proxied data model if the change’s number of columns match the proxied data model’s number of columns and based on:

  • the contents of the proxied data model’s modified row for updates and deletes

  • the inserts are always kept

New in version 5.2.

Gda.DataProxy.props.defer_sync
Name:

defer-sync

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Tells if changes to the sample of rows displayed is done in background in several steps or if it’s done in one step.

Gda.DataProxy.props.model
Name:

model

Type:

Gda.DataModel

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

Proxied data model

Gda.DataProxy.props.prepend_null_entry
Name:

prepend-null-entry

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Tells if a row composed of None values is inserted as the proxy’s first row

Gda.DataProxy.props.sample_size
Name:

sample-size

Type:

int

Default Value:

300

Flags:

READABLE, WRITABLE, CONSTRUCT

Number of rows which the proxy will contain at any time, like a sliding window on the proxied data model