RQList¶
- class pyreaqtive.models.rqlist.RQListIndex(item: pyreaqtive.models.rqmodel.RQModel, initial: pyreaqtive.models.rqlist.RQList)¶
Bases:
pyreaqtive.models.rqint.RQIntReactive Index of a Item in a List
- INVALID_INDEX_VALUE = -1¶
Value if item is not present in list
- __init__(item: pyreaqtive.models.rqmodel.RQModel, initial: pyreaqtive.models.rqlist.RQList)¶
Constructor
- Parameters
item – item that presumably is on the list
initial – list where to search the item
- _get_index_int() → int¶
- _int: int¶
Model store variable
- class pyreaqtive.models.rqlist.RQList(initial_models: Optional[List[pyreaqtive.models.rqmodel.RQModel]] = 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.
- 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_models: Optional[List[pyreaqtive.models.rqmodel.RQModel]] = None)¶
Constructor
- Parameters
initial_models – List of model instances
- _list: List[pyreaqtive.models.rqmodel.RQModel]¶
Model store variable
Stores instances of models
- set(value) → None¶
Method to set the value of the underlying object.
Must be overridden by model
- Parameters
value – New value of the model
- get() → list¶
Get value of the model
- Returns
value of the model
- Return type
list
- insert(index, model: pyreaqtive.models.rqmodel.RQModel) → None¶
Insert a model instance to the specified index on the list
- Parameters
index – positional index on the list
model – Model to be inserted
Returns:
- append(model: pyreaqtive.models.rqmodel.RQModel) → None¶
Append a model instance to the end of the list
- Parameters
model – Model to be appended
Returns: Instance of the model
- __delitem__(index) → None¶
Delete the item in the list in the specified index
- Parameters
index – positional index on the list
- pop() → None¶
Delete last instance of the list
- remove(item: pyreaqtive.models.rqmodel.RQModel) → None¶
Remove first occurrence of value
- Parameters
item – model item
- remove_all(item: pyreaqtive.models.rqmodel.RQModel) → None¶
Remove all instances in the list
- Parameters
item – model item
- clear() → None¶
Clear all items of the list
- __getitem__(index: int) → pyreaqtive.models.rqmodel.RQModel¶
Returns the indicated item of the list
- Parameters
index – element of the list
- Returns
item in the list indicated by index
- Return type
- index(item: pyreaqtive.models.rqmodel.RQModel) → int¶
Returns the index where a item is located
Raises an ValueError if is not in the list
- Parameters
item – instance that should be in the list
- Returns
index of the item in the list
- Return type
int
- reactive_index(item: pyreaqtive.models.rqmodel.RQModel) → pyreaqtive.models.rqlist.RQListIndex¶
Returns a reactive index model that indicates where the item is located
- Parameters
item – instance that should be in the list
- Returns
reactive index of the item in the list
- Return type
- __iter__() → Iterator[pyreaqtive.models.rqmodel.RQModel]¶
Iterator of the elements of the list
- Returns
Iterator of RQModels
- __len__() → int¶
Length of the list
- count(value) → int¶
Same as python list method
- extend(iterable: List[pyreaqtive.models.rqmodel.RQModel])¶
Same as python list method
- __contains__(item: pyreaqtive.models.rqmodel.RQModel) → bool¶
Same as python list method
- class pyreaqtive.models.rqlist.RQComputedList(function: Callable, **kwargs)¶
Bases:
pyreaqtive.models.rqlist.RQList,pyreaqtive.models.rqmodel.RQComputedModelReactive Computed List Model
- __init__(function: Callable, **kwargs)¶
Constructor
- Parameters
function – 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() → None¶
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.
- _list: List[pyreaqtive.models.rqmodel.RQModel]¶
Model store variable
Stores instances of models
- get() → list¶
See overridden method
ComputedLists are recalculated on change, not on request, so this just redirects to the actual list.
- insert(index, model: pyreaqtive.models.rqmodel.RQModel) → None¶
Insert a model instance to the specified index on the list
- Parameters
index – positional index on the list
model – Model to be inserted
Returns:
- __delitem__(key)¶
Delete the item in the list in the specified index
- Parameters
index – positional index on the list