easymodel.cascade.AbstractLevel¶
-
class
easymodel.cascade.
AbstractLevel
(*args, **kwargs)[source]¶ Bases:
object
Mixin for
QtGui.QWidget
for a level of a cascade view.A level is a widget that should display data of a specific root index of its model. So it can be just a regular view, but it can also be a combobox. It can also emit a signal to state that the level below this one should have a new root index. You are free to emit the signal whenever you want.
When subclassing implement
AbstractLevel.model_changed()
,AbstractLevel.set_root()
,AbstractLevel.selected_indexes()
.Constructs a new level. All arguments will be passed on.
Raises: None -
__init__
(*args, **kwargs)[source]¶ Constructs a new level. All arguments will be passed on.
Raises: None
Methods
__init__
(*args, **kwargs)Constructs a new level. get_model
()Return the model model_changed
(model)Abstract method that should handle the case that someone set the model selected_indexes
()Abstract method that should return the “selected” indexes. set_index
(index)Set the current index of the level to the given one set_model
(model)Set the model set_root
(index)Abstract method that should make the level use the given index as root Attributes
new_root
This signal says that the level under this one should update its root index to the one of the signal. -
new_root
= <PySide.QtCore.Signal object>¶ This signal says that the level under this one should update its root index to the one of the signal.
-
get_model
()[source]¶ Return the model
Returns: the model Return type: QtGui.QAbstractItemModel
Raises: None
-
set_model
(model)[source]¶ Set the model
Parameters: model ( QtGui.QAbstractItemModel
) – The value for modelRaises: None
-
model_changed
(model)[source]¶ Abstract method that should handle the case that someone set the model
When a level instance is created, the model is None. So it has to be set afterwards. Then this method will be called and your level should somehow use the model
Parameters: model ( QtCore.QAbstractItemModel
| None) – the model that the level should use | NoneReturns: None Return type: None Raises: NotImplementedError
-
set_root
(index)[source]¶ Abstract method that should make the level use the given index as root
The index might also be invalid! In that case show an empty level. If the index has been of a different model, the model was set automatically before calling this method.
Parameters: index ( QtCore.QModelIndex
) – the new root indexReturns: None Return type: None Raises: NotImplementedError
-
selected_indexes
()[source]¶ Abstract method that should return the “selected” indexes.
Selected does not mean, selected like Qt refers to the term. It just means that this level has some indexes that seems to be of importance right now. E.g. your level is a combobox, then the selected indexes would just consist of the current index. If your level is a regular view, then you could indeed return the selected indexes.
Returns: the ‘selected’ indexes of the level Return type: list of QtCore.QModelIndex
Raises: NotImplementedError
-
set_index
(index)[source]¶ Set the current index of the level to the given one
The given index should be the new root for levels below. You should make sure that the new_root signal will be emitted.
Parameters: index ( QtCore.QModelIndex
) – the new indexReturns: None Return type: None Raises: NotImplementedError
-