MeVisLab Scripting Reference
|
Public Slots | |
Changing the model. | |
| |
virtual int | getChildPosition (const ModelIndexWrapper *child) |
virtual void | clear () |
virtual void | insertItems (const ModelIndexWrapper *parent, unsigned int position, const QVariant &items) |
virtual ModelIndexWrapper * | insertItem (const ModelIndexWrapper *parent, unsigned int position, const QVariantMap &itemData) |
virtual void | appendItems (const ModelIndexWrapper *parent, const QVariant &items) |
virtual ModelIndexWrapper * | appendItem (const ModelIndexWrapper *parent, const QVariantMap &itemData) |
virtual void | removeItems (const ModelIndexWrapper *parent, unsigned int position, unsigned int numItems) |
virtual void | removeItem (ModelIndexWrapper *index) |
Public Slots inherited from MLAbstractItemModelWrapper | |
QObject * | qmlModel () const |
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) |
int | getAttributeCount () const |
QStringList | getAttributeNames () const |
QString | getAttributeName (int index) const |
QVariant | getAttributeDefault (int index) const |
int | getAttributeIndex (const QString &name) |
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) |
QVariant | getData (const ModelIndexWrapper *item, const QString &attributeName) |
bool | setData (const ModelIndexWrapper *item, const QString &attributeName, const QVariant &data) |
bool | bulkSetData (const QList< ModelIndexWrapper * > &items, const QString &attributeName, const QVariant &data) |
Signals | |
Signals | |
| |
void | childrenRequest (ModelIndexWrapper *item) |
Signals inherited from MLAbstractItemModelWrapper | |
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) |
Static Public Member Functions | |
static ml::RefCountedBase * | createObject (const QVariantList &arguments) |
This class wraps the class ml::StandardItemModel and thus provides an item model that can be created from scripting.
For a working example on how to use this to fill a self-defined model dynamically, have a look at the source code of the FileSystemItemModelData and the FileSystemItemModelView macro modules.
|
virtualslot |
Same as insertItem, but always appends at the end of the list.
|
virtualslot |
Same as insertItems, but always appends at the end of the list.
|
signal |
The children of an item are requested for the first time. This can be used to add direct children of this item dynamically when they are requested with insertItems (which will generate no itemsInserted signal for this very item).
Example:
|
virtualslot |
Clears the complete model (the attributes are still the same, though).
|
static |
Creates new item model; this is used by MLAB.createMLBaseObject to create a StandardItemModel. This takes a list with 1 to 3 arguments.
The first, required element is the list of attribute names.
The second, optional element is the index or name of an attribute indicating if an item might have children. If set, children can be added dynamically by listening to the childrenRequest signal. Use -1 if you do not need this feature and want to specify the third argument.
The third, optional element is a bool. If it is set to True, it is a hint that the model will have no subitems. This can be used by views to avoid reserving space for subitem indicators.
Example:
|
virtualslot |
Returns the position index of the given child relative to its parent.
|
virtualslot |
Similar as above, but only one object can be inserted. This method returns the ModelIndex of the newly inserted item, which can be used for further operations.
|
virtualslot |
Inserts new items, this can take a dictionary or a list of dictionaries. Example:
or
Note that you may only use keys that were provided when creating the model.
|
virtualslot |
Convenience method, removes the given item from the model, e.g.:
Note that the index will of course be invalid afterwards.
|
virtualslot |
Removes items, e.g.: