MeVisLab Scripting Reference
|
#include <mlAbstractItemModelWrapper.h>
Inherits MLRefCountedBaseWrapper.
Inherited by MLPythonItemModelWrapper, and MLStandardItemModelWrapper.
Public Slots | |
QObject * | qmlModel () const |
Item traversal interface | |
| |
bool | isFlat () const |
bool | hasChildren (const ModelIndexWrapper *parent) |
int | getChildCount (const ModelIndexWrapper *parent) |
ModelIndexWrapper * | getChild (const ModelIndexWrapper *parent, unsigned int index) |
ModelIndexWrapper * | getParent (const ModelIndexWrapper *child) |
ModelIndexWrapper * | findFirst (const QVariant &attribute, const QVariant &value) |
ModelIndexWrapper * | searchItem (const QVariant &attribute, const QVariantList &values) |
Attribute discovery | |
| |
int | getAttributeCount () const |
QStringList | getAttributeNames () const |
QString | getAttributeName (int index) const |
QVariant | getAttributeDefault (int index) const |
int | getAttributeIndex (const QString &name) |
Data access | |
| |
QVariant | getData (const ModelIndexWrapper *item, int attributeIndex) |
bool | setData (const ModelIndexWrapper *item, int attributeIndex, const QVariant &data) |
bool | bulkSetData (const QList< ModelIndexWrapper * > &items, int attributeIndex, const QVariant &data) |
Data access with attribute name instead of attribute index | |
|
Signals | |
Signals | |
| |
void | itemChanged (ModelIndexWrapper *item, bool after) |
void | itemsInserted (ModelIndexWrapper *parent, unsigned int childIndex, unsigned int itemsInserted, bool after) |
void | itemsRemoved (ModelIndexWrapper *parent, unsigned int childIndex, unsigned int itemsRemoved, bool after) |
void | dataChanged (const QList< ModelIndexWrapper * > &items, const QList< int > &attributeIndices) |
This class wraps the class ml::AbstractItemModel.
|
slot |
Update several items at once. The data can be a single value that is set on all items or a list of values (which must have the same length as the items list. This will return false if not all changes were accepted.
To react on such changes if you created the model yourself with MLStandardItemModelWrapper, connect to the signal MLAbstractItemModelWrapper::dataChanged
|
signal |
Attributes have changed on the given items.
Example:
|
slot |
Recursively find the first item in the model where the given attribute (given as index or name) has the given value.
The search is performed depth-first.
|
slot |
Get number of defined attributes for this model.
|
slot |
Return default value of n-th attribute.
This is used to conserve space during serialization of items. This method returns an None by default.
|
slot |
Get index of attribute with the given name.
Returns -1 if the attribute name doesn't exist in the model.
|
slot |
Get name of n-th attribute.
|
slot |
Get names of all attributes.
|
slot |
Get n-th child of an item (or n-th top-level item if parent index is None). This will return None for indices out of range, but also see the description of getChildCount for important details.
Example for fully recursive traversal of a model in Python:
|
slot |
Get number of children of the given item, an invalid index (i.e. None in Python) means get the number of top-level items. This should be called before accessing any children, because this is the signal for dynamic models to actually provide the children.
|
slot |
Get attribute value of a certain item. This will return the default value if the attribute wasn't specified for the requested item and None if the attribute isn't specified in this model at all.
Note that you can't specify default values when creating the model yourself with the MLStandardItemModelWrapper.
|
slot |
Get parent of an item. Will return None for top-level items.
|
slot |
This method tells us if an item has children - at least in principle. This is used to display the item as having children, even if it might turn out that is has actually none.
You should prefer to call hasChildren instead of getChildCount if you only need to know if there are children, since dynamic models will delay providing the actual children until the number of children is requested.
|
slot |
This method tells you if you can expect items in this model to have no sub-items.
|
signal |
The children of an item will change completely/have completely changed.
If you are interested in such changes - most likely if you didn't create the model yourself and know that it can change - connect to this signal like this:
|
signal |
An item gets/got additional children.
Example:
|
signal |
An item loses/lost additional children.
Example:
|
slot |
Return a model for use in QML/the QuickView control.
Everything maps to the first column, the attributes directly map to roles.
Also see the Qt documentation on using QAbstractItemModel with QtQuick views
|
slot |
Almost as above, but the values give a hierarchical path to the item, i.e.
the first value is matched on a top-level item, then the search is continued from that item down with a value list reduced by the first element.
|
slot |
Update a single attribute on a single item. This will return false if the change wasn't accepted by the model.
Note: If you want to set a icon file path as attribute, you need to pass a dict with the keys "type" set to "FilePath", and "path" set to the path of the icon, like
This is required because for some use cases the file path needs to be transformed before the icon can be displayed.