### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- view »
- proxy »

# collection_proxy

Proxy representing a collection of entities that live in the model thread.

The proxy represents them in the gui thread and provides access to the data with zero delay. If the data is not yet present in the proxy, dummy data is returned and an update signal is emitted when the correct data is available.

class `camelot.view.proxy.collection_proxy.``CollectionProxy`(*args, **kwargs)

  The CollectionProxy contains a limited copy of the data in the actual collection, usable for fast visualisation in a QTableView

  the CollectionProxy has some class attributes that can be overwritten when subclassing it :

  - header_icon : the icon to be used in the vertical header
  `append_object`(*args, **kwargs)

    Append an object to this collection, set the possible defaults and flush the object if possible/needed

    Parameters: | obj – the object to be added to the collection
    Returns: | the new number of rows in the collection

  `append_row`(*args, **kwargs)

    Parameters: | object_getter – a function that returns the object to be put in the

    appended row.

  `copy_row`(*args, **kwargs)

    Copy the entity associated with this row to the end of the collection :param row: the row number

  `data`(*args, **kwargs)

    Returns: | the data at index for the specified role

    This function will return ValueLoading when the data has not yet been fetched from the underlying model. It will then send a request to the model thread to fetch this data. Once the data is readily available, the dataChanged signal will be emitted

    Using Qt.UserRole as a role will return all the field attributes of the index.

    Using Qt.UserRole+1 will return the object of which an attribute is displayed in that specific cell

  `flags`(index)

    Returns the item flags for the given index

  `getColumns`()

    Returns: | the columns as set by the setColumns method

  `getData`(*args, **kwargs)

    Generator for all the data queried by this proxy

  `getItemDelegate`()

    Returns: | a DelegateManager for this model, or None if no DelegateManager yet available

    a DelegateManager will be available once the item_delegate_changed signal has been emitted

  `get_admin`()

    Get the admin object associated with this model

  `handleRowUpdate`(*args, **kwargs)

    Handles the update of a row when this row might be out of date

  `handle_entity_create`(sender, entity)

    Handles the entity signal, indicating that the model is out of date

  `handle_entity_delete`(sender, entity)

    Handles the entity signal, indicating that the model is out of date

  `handle_entity_update`(sender, entity)

    Handles the entity signal, indicating that the model is out of date

  `hasUnflushedRows`()

    The model has rows that have not been flushed to the database yet, because the row is invalid

  `headerData`(*args, **kwargs)

    In case the columns have not been set yet, don’t even try to get information out of them

  `map_to_source`(sorted_row_number)

    Converts a sorted row number to a row number of the source collection

  `max_number_of_rows`

    The maximum number of rows to be displayed at once

  `remove_objects`(*args, **kwargs)

    Parameters: | objects_to_remove – a list of objects that need to be removed

    from the collection :param delete: True if the objects need to be deleted

  `remove_rows`(*args, **kwargs)

    Remove the entity associated with this row from this collection @param rows: a list with the numbers of the rows to remove @param delete: delete the entity as well

    The rows_removed signal will be emitted when the removal was successful, otherwise the exception_signal will be emitted.

  `setColumns`(*args, **kwargs)

    Callback method to set the columns

    Parameters: | columns – a list with fields to be displayed of the form [(‘field_name’, field_attributes), ...] as

    returned by the getColumns method of the ElixirAdmin class

  `setData`(index, value, role=2)

    Value should be a function taking no arguments that returns the data to be set

    This function will then be called in the model_thread

  `setRowCount`(rows)

    Callback method to set the number of rows @param rows the new number of rows

  `sort`(*args, **kwargs)

    reimplementation of the QAbstractItemModel its sort function

class `camelot.view.proxy.collection_proxy.``DelayedProxy`(*args, **kwargs)

  A proxy object needs to be constructed within the GUI thread. Construct a delayed proxy when the construction of a proxy is needed within the Model thread. On first occasion the delayed proxy will be converted to a real proxy within the GUI thread

class `camelot.view.proxy.collection_proxy.``ProxyDict`

  Subclass of dictionary to fool the QVariant object and prevent it from converting dictionary keys to whatever Qt object, but keep everything python

class `camelot.view.proxy.collection_proxy.``SortingRowMapper`

  Class mapping rows of a collection 1:1 without sorting and filtering, unless a mapping has been defined explicitly

`camelot.view.proxy.collection_proxy.``strip_data_from_object`(*args, **kwargs)

  For every column in columns, get the corresponding value from the object. Getting a value from an object is time consuming, so using this function should be minimized. :param obj: the object of which to get data :param columns: a list of columns for which to get data

`camelot.view.proxy.collection_proxy.``stripped_data_to_unicode`(*args, **kwargs)

  Extract for each field in the row data a ‘visible’ form of data

### Navigation

- index
- modules |
- next |
- previous |
- Camelot documentation »
- Camelot API »
- view »
- proxy »

Comments
blog comments powered by Disqus