Acces to db made easy

- Home
- Sqlkit
  - Sqlkit
  - Widgets
    - Mask view
    - Table view
  - Browsing data
    - Constraints
    - Filters
    - Totals
  - Editing data
    - Completion
    - Validation
    - Relationships
  - Printing
  - Advanced configuration
    - Fields
    - Views
- Sqledit GUI
- Support & Tutorials
  - Sqledit - the application
  - Sqlkit - features' tour
  - Installing instructions
- Layout
- Download
  - Download
  - Changelog
  - Backward incompatibilities

- Prev: Fields
- Next: Utilities

# ModelProxy

A proxy to the treeview model that can handle both listore and treemodels and allows to switch easily from one to the other

A second purpouse is to allow reorderable treeviews (i.e.: those wehere you can set order by drag&drop) via self.order_store attribute/function. If position of rows need to be memorized in a visual way, a field must be set (order_store) that will be reset each time a new record is added or a row is dragged.

Clearly if that means something at all, entirely depends on the application. In these cases the order is set in the records currently handled by the model.

## Sorting

A modelproxy can be sorted via it’s `order_by` method. This sorting is done locally as opposed to the sorting done setting `SqlWidget.order_by` attribute on the table

## Signals

a modelproxy emits signals:

model-pre-sort: | This signal is emitted just before sorting the model. Used to get rid of possible “total rows” in the liststore.
model-sorted: | When the model is sorted. Totals listen to this signal to be informed they must refresh data
model-changed: | the model has changed the content

`sqlkit.widgets.table.modelproxy.``modelstore`
  the ListStore or TreeStore for which this ModelProxy is a Proxy.

class `sqlkit.widgets.table.modelproxy.``ModelProxy`(master, tree_field_name=None, treeview=None, order_store=None)
  `__init__`(master, tree_field_name=None, treeview=None, order_store=None)

    Parameters: | master – the sqlwidget this belongs or another modelproxy to copy tree_field_name – the field_name that will hold parent/child relationship. Defaults to None treeview – the treeview to set the model for or None for later setting. order_store – the field_name where the path should be stored

  `copy`(class_)

    Ceate another ModelProxy of class `class_` with the same other values

    Parameter: | class – class of the new ModelProxy, a descendent of ModelProxy. Used when you need to add a function to create a Header (see example 02a)

  `order_by`(order_list, view='main')

    set order for the model if it’s a ListStore

    Parameter: | order_list – fields to use to order, e.g.: +status -description to get an ascending ordering on status and descending on description implemented just for one attribute

  `tree_field_name`
    The field on which you want to group rows

# View

Classes that implement creation of column and cell renderers This should allow to be as generic as possible while adding new renderers

Each Column widget need a ‘master’ argument that is the SqlWidget in editing_started_cb and edited_cb to set state variables on SqlWidget

class `sqlkit.widgets.table.columns.``View`(master, name, treeview=None, field_list=None, cell_renderers=None, ro=False)

  A View is a set of columns of the SqlTable’s that offers a (possibly partial) view of the model. Each SqlTable has one mandatory view named `main` and possibly other views. Attribute `sqlkit.widgets.SqlTable.views` (a sqlkit.utils.Container) stores them.

  It can be used to provide different way to look at the same data (e.g. different cell-renderers) or different columns for long ones

  `add_column`(column=None, position=-1, field=None)

    Add a column to the view.

    Parameters: | column – the column to be added. If empty, a field must be provided position – where should the column be inserted field – an instance of the Field that should be used. In this case a column is guessed and built on the fly by `setup_columns()`

  `select_path`(path=None, obj=None, sync=True)

    Select path `path`. If path is null and obj is not null try finding path at which is obj

    Parameters: | path – the path to be selected or None obj – if path is None, the object to be searched for and selected sync (boolean) – syncronize all views but run just one selection_cb

  `start_editing`(path, field_name=None)

    Edit a path/column. Column is passed by its field_name

    Parameters: | path – the path to be edited field_name – the field_name of the column, if None, the first editable field that does not have a default