RQList¶
- class pyreaqtive.models.rqlist.RQListIndex(item, initial)¶
Bases:
pyreaqtive.models.rqint.RQIntReactive Index of a Item in a List
- Parameters
item (Any) –
initial (RQList) –
- INVALID_INDEX_VALUE = -1¶
Value if item is not present in list
- __init__(item, initial)¶
Constructor
- Parameters
item (Any) – item that presumably is on the list
initial (pyreaqtive.models.rqlist.RQList) – list where to search the item
- _get_index_int()¶
- Return type
int
- _int: int¶
Model store variable
- class pyreaqtive.models.rqlist.RQList(initial_items=None)¶
Bases:
pyreaqtive.models.rqmodel.RQModelReactive List Model
Represents a list of model instances
This model is quite different from the others and doesn’t use data_changed signal. Instead it uses insert and remove signals that indicate the index of the list where this event is happening. This can greatly improve the efficiency of widgets that use this model.
- Parameters
initial_items (List[Any]) –
- rq_list_insert¶
List insert signal.
Indicates that there’s been an insertion to the position indicated by the int
- rq_list_remove¶
List remove signal.
Indicates that there’s been an deletion in the position indicated by the int
- __init__(initial_items=None)¶
Constructor
- Parameters
initial_items (Optional[List[Any]]) – List of items
- _list: List[Any]¶
Model store variable
Stores list of instances
- set(value)¶
Method to set the value of the underlying object.
Must be overridden by model
- Parameters
value – New value of the model
- Return type
None
- get()¶
Get value of the model
- Returns
value of the model
- Return type
list
- insert(index, item)¶
Insert a item to the specified index on the list
- Parameters
index (int) – positional index on the list
item (Any) – item to be inserted
- Return type
None
Returns:
- append(item)¶
Append a item to the end of the list
- Parameters
item (Any) – Item to be appended
- Return type
None
- __delitem__(index)¶
Delete the item in the list in the specified index
- Parameters
index – positional index on the list
- Return type
None
- pop()¶
Delete last instance of the list
- Return type
None
- remove(item)¶
Remove first occurrence of value
- Parameters
item (Any) – item
- Return type
None
- remove_all(item)¶
Remove all instances in the list
- Parameters
item (Any) – item
- Return type
None
- clear()¶
Clear all items of the list
- Return type
None
- __getitem__(index)¶
Returns the indicated item of the list
- Parameters
index (int) – element of the list
- Returns
item in the list indicated by index
- Return type
Any
- index(item)¶
Returns the index where a item is located
Raises an ValueError if is not in the list
- Parameters
item (Any) – instance that should be in the list
- Returns
index of the item in the list
- Return type
int
- reactive_index(item)¶
Returns a reactive index model that indicates where the item is located
- Parameters
item (Any) – instance that should be in the list
- Returns
reactive index of the item in the list
- Return type
- __iter__()¶
Iterator of the elements of the list
- Returns
Iterator of RQModels
- Return type
Iterator[Any]
- __len__()¶
Length of the list
- Return type
int
- count(value)¶
Same as python list method
- Return type
int
- extend(iterable)¶
Same as python list method
- Parameters
iterable (List[Any]) –
- __contains__(item)¶
Same as python list method
- Parameters
item (Any) –
- Return type
bool
- class pyreaqtive.models.rqlist.RQComputedList(function, **kwargs)¶
Bases:
pyreaqtive.models.rqlist.RQList,pyreaqtive.models.rqmodel.RQComputedModelReactive Computed List Model
- Parameters
function (Callable) –
- __init__(function, **kwargs)¶
Constructor
- Parameters
function (Callable) – function to calculate the model value from input values
**kwargs – reactive models in the function by variable name as keyword Changes in these models will trigger recalculation of the function
- _variable_changed()¶
Variable changed slot
Called when some of the models have emitted rq_data_changed.
Recalculates the list with the function and calculates differences with the current list, inserting and deleting the differences.
- Return type
None
- _list: List[Any]¶
Model store variable
Stores list of instances
- get()¶
See overridden method
ComputedLists are recalculated on change, not on request, so this just redirects to the actual list.
- Return type
list
- insert(index, model)¶
Insert a item to the specified index on the list
- Parameters
index – positional index on the list
item – item to be inserted
model (Any) –
- Return type
None
Returns:
- __delitem__(key)¶
Delete the item in the list in the specified index
- Parameters
index – positional index on the list