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(admin, max_number_of_rows=10, flush_changes=True, cache_collection_proxy=None)[source]¶
The CollectionProxy contains a limited copy of the data in the actual collection, usable for fast visualisation in a QtWidgets.QTableView
The behavior of the QtWidgets.QTableView, such as what happens when the user clicks on a row is defined in the ObjectAdmin class.
- append_object(obj)[source]¶
Append an object to this collection
Parameters: obj – the object to be added to the collection Returns: the new number of rows in the collection
- data(index, role=0)[source]¶
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
- handle_entity_create(sender, entity)[source]¶
Handles the entity signal, indicating that the model is out of date
- handle_entity_delete(sender, obj)[source]¶
Handles the entity signal, indicating that the model is out of date
- handle_entity_update(sender, entity)[source]¶
Handles the entity signal, indicating that the model is out of date
- hasUnflushedRows()[source]¶
The model has rows that have not been flushed to the database yet, because the row is invalid
- headerData(section, orientation, role)[source]¶
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)[source]¶
Converts a sorted row number to a row number of the source collection
- setData(index, value, role=2)[source]¶
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)[source]¶
Callback method to set the number of rows @param rows the new number of rows
- class camelot.view.proxy.collection_proxy.ProxyDict[source]¶
Subclass of dictionary to fool the Qt Variant object and prevent it from converting dictionary keys to whatever Qt object, but keep everything python
- class camelot.view.proxy.collection_proxy.RowModelContext[source]¶
A list action model context for a single row. This context is used to get the state of the list action on a row
- class camelot.view.proxy.collection_proxy.SortingRowMapper[source]¶
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(obj, columns)[source]¶
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