|
MeVisLab Toolbox Reference
|
#include <mlAbstractItemModel.h>
Public Member Functions | |
| virtual bool | isFlat () const |
| item traversal interface | |
| virtual bool | hasChildren (const ModelIndex &parent) |
| virtual unsigned int | getChildCount (const ModelIndex &parent)=0 |
| virtual ModelIndex | getChild (const ModelIndex &parent, unsigned int index)=0 |
| virtual ModelIndex | getParent (const ModelIndex &child)=0 |
| virtual int | getAttributeCount () const =0 |
| Attribute discovery. | |
| virtual std::string | getAttributeName (int index) const =0 |
| Returns the name of n-th attribute. Must be overridden. | |
| virtual Variant | getAttributeDefault (int index) const |
| virtual int | getAttributeIndex (const std::string &name) |
| virtual Variant | getData (const ModelIndex &item, int attributeIndex)=0 |
| Data access. | |
| virtual bool | setData (const ModelIndex &item, int attributeIndex, const Variant &data, void *skipListener=nullptr) |
| virtual bool | bulkSetData (const std::vector< ModelIndex > &items, int attributeIndex, const Variant &data, void *skipListener=nullptr) |
| virtual bool | bulkSetData (const std::vector< ModelIndex > &items, int attributeIndex, const std::vector< Variant > &data, void *skipListener=nullptr) |
| Public Member Functions inherited from ml::RefCountedBase | |
| RefCountedBase () | |
| Constructor. | |
| RefCountedBase (const RefCountedBase &) | |
| Explicit copy constructor. | |
| virtual void | incRefCount () const |
| Increases the reference count. | |
| virtual void | decRefCount () const |
| Decreases the reference count (object will be deleted if the reference count is decremented to 0). | |
| bool | isRefCountedBase () const override |
| Returns whether the instance is derived from RefCountedBase. | |
| Public Member Functions inherited from ml::EventSource | |
| EventSource () | |
| EventSource (const EventSource &evSource) | |
| ~EventSource () override | |
| void | addEventListener (BaseEventCallback *cb, void *userData) |
| void | removeEventListener (BaseEventCallback *cb, void *userData) |
| bool | hasEventListeners () const |
| Public Member Functions inherited from ml::Base | |
| Base () | |
| Constructor. | |
| virtual | ~Base () |
| Destructor. | |
| virtual Base * | deepCopy () const |
| bool | isOfAllowedType (const std::vector< const RuntimeType * > &types) const |
| virtual std::string | detailString () const |
| virtual bool | implementsPersistence (PersistenceInterface) const |
| virtual std::string | persistentState () const |
| Returns a string describing the object's internal state. | |
| virtual void | setPersistentState (const std::string &state) |
| virtual void | addStateToTree (TreeNode *) const |
| Attaches the object state as children of the given parent node. | |
| virtual void | readStateFromTree (TreeNode *) |
| Reads the object state from the children of the given parent node. | |
| virtual void | writeTo (AbstractPersistenceOutputStream *) const |
| virtual void | readFrom (AbstractPersistenceInputStream *, int) |
Protected Member Functions | |
| AbstractItemModel () | |
| virtual bool | rawSetData (const ModelIndex &item, int attributeIndex, const Variant &data)=0 |
| ModelIndex | createIndex (void *data) |
| ModelIndex | createIndex (size_t data) |
| virtual void | incItemRefCount (void *) |
| Implement this if the pointer in the model indices needs explicit reference counting. | |
| virtual void | decItemRefCount (void *) |
| virtual void | notifyItemChanged (const ModelIndex &item, bool after, void *skipListener=nullptr) |
| change notifications | |
| virtual void | notifyItemsInserted (const ModelIndex &parent, unsigned int childIndex, unsigned int itemsInserted, bool after, void *skipListener=nullptr) |
| virtual void | notifyItemsRemoved (const ModelIndex &parent, unsigned int childIndex, unsigned int itemsRemoved, bool after, void *skipListener=nullptr) |
| virtual void | notifyItemsDataChanged (const std::vector< ModelIndex > &items, const std::vector< int > &attributeIndices, void *skipListener=nullptr) |
| Protected Member Functions inherited from ml::RefCountedBase | |
| ~RefCountedBase () override | |
| Destructor. | |
| Protected Member Functions inherited from ml::EventSource | |
| void | sendEvent (BaseEvent *event, void *skipListener=nullptr) |
Friends | |
| class | ItemModelProxy |
| class | ModelIndex |
Additional Inherited Members | |
| Public Types inherited from ml::Base | |
| enum | PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream } |
| This enum describes the different persistence interfaces available. More... | |
| Static Public Member Functions inherited from ml::RefCountedBase | |
| static void | updateReferenceCountingIfSupported (Base *oldValue, Base *newValue, bool &isRefCountedBase) |
| Protected Attributes inherited from ml::RefCountedBase | |
| std::atomic_int_least32_t | _refCount |
| Reference count. | |
This class represents an abstract hierarchical item model where the items have named attributes which can be queried and even modified. It has a notification system in place to inform about changes to the model. This is loosely modeled after the QAbstractItemModel class from Qt.
Definition at line 90 of file mlAbstractItemModel.h.
|
inlineprotected |
Definition at line 175 of file mlAbstractItemModel.h.
Referenced by bulkSetData().
|
virtual |
This method can be used to update whole columns with varying data. This will return false if not all changes were accepted. This will call rawSetData.
Reimplemented in ml::ItemModelAttributeFilter, and ml::ItemModelItemFilter.
References AbstractItemModel().
|
virtual |
This method will be used by views to set selection state to an attribute, so that we only get a single update notification. This is important for remote handling. This will return false if not all changes were accepted. This will call rawSetData.
Reimplemented in ml::ItemModelAttributeFilter, and ml::ItemModelItemFilter.
|
protected |
References ModelIndex.
|
protected |
Creates a model index, either with a pointer value or with an integer value. Note: this does not call incItemRef.
References ModelIndex.
|
inlineprotectedvirtual |
Reimplemented in ml::ItemModelProxy.
Definition at line 191 of file mlAbstractItemModel.h.
|
pure virtual |
Attribute discovery.
Returns the number of defined attributes for this model. Must be overridden.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
|
virtual |
Returns the default value of n-th attribute. This is used to conserve space during serialization of items. This method returns an invalid value by default.
Reimplemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
|
virtual |
Returns the index of attribute with the given name. Returns -1 if the attribute name does not exist in the model.
Reimplemented in ml::ItemModelAttributeFilter, and ml::ItemModelItemFilter.
|
pure virtual |
Returns the name of n-th attribute. Must be overridden.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
|
pure virtual |
Returns the n-th child of an item (or n-th top-level item if parent index is invalid). Note: Do not call this before calling getChildCount on the parent, since this is the signal for the model that the children must really be provided! Must be overridden.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
References ModelIndex.
|
pure virtual |
Returns the number of children of the given item, an invalid index means number of top-level items. This will be only called if the children are really accessed, so the children might be dynamically created the first time this method is called for an item. Must be overridden.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
References ModelIndex.
|
pure virtual |
Data access.
Returns the attribute value of a certain item. Must be overridden.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
References ModelIndex.
|
pure virtual |
Returns the parent of an item. Will return invalid index for top-level items. Must be overridden.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
References ModelIndex.
|
virtual |
Or rather mightHaveChildren. 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 none actually. The default for this method is to return true if getChildCount returns a number != 0 or if the model index is invalid.
Reimplemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
References ModelIndex.
|
inlineprotectedvirtual |
Implement this if the pointer in the model indices needs explicit reference counting.
Reimplemented in ml::ItemModelProxy.
Definition at line 190 of file mlAbstractItemModel.h.
|
inlinevirtual |
item traversal interface
Returns a hint if this model is flat (in contrast to being hierarchical, i.e., if it will have subitems).
Reimplemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
Definition at line 99 of file mlAbstractItemModel.h.
|
protectedvirtual |
change notifications
Notifies listeners that an items children have completely changed. This must be called once before the changed and once after the change (set second argument accordingly).
If a skipListener is specified, all event listeners with this value for userData are not notified of the change.
References ModelIndex.
|
protectedvirtual |
Notifies listeners that attributes have changed on the given items. This must be called after the change.
If a skipListener is specified, all event listeners with this value for userData are not notified of the change.
|
protectedvirtual |
Notifies listeners that an item gets/got additional children. This must be called once before the changed and once after the change (set second argument accordingly).
If a skipListener is specified, all event listeners with this value for userData are not notified of the change.
References ModelIndex.
|
protectedvirtual |
Notifies listeners that an item loses/lost additional children. This must be called once before the changed and once after the change (set second argument accordingly).
If a skipListener is specified, all event listeners with this value for userData are not notified of the change.
References ModelIndex.
|
protectedpure virtual |
This will be called by setData and bulkSetData, which will do the necessary notifications afterwards; attributeIndex does not need to be checked for valid range, this has already been done when this method is called.
Implemented in ml::ItemModelAttributeFilter, ml::ItemModelItemFilter, and ml::StandardItemModel.
References ModelIndex.
|
virtual |
Updates a single attribute on a single item. This will return false if the change was not accepted by the model. skipListener denotes an event listener which should not be notified of this change. This will call rawSetData, which must be overridden
Reimplemented in ml::ItemModelAttributeFilter, and ml::ItemModelItemFilter.
References ModelIndex.
|
friend |
Definition at line 92 of file mlAbstractItemModel.h.
References ItemModelProxy.
Referenced by ItemModelProxy.
|
friend |
Definition at line 173 of file mlAbstractItemModel.h.
References ModelIndex.
Referenced by ml::StandardItemModel::addItem(), ml::ItemModelProxy::convertFromSource(), ml::ItemModelProxy::convertToSource(), createIndex(), createIndex(), getChild(), ml::StandardItemModel::getChild(), getChildCount(), ml::StandardItemModel::getChildCount(), ml::StandardItemModel::getChildPosition(), getData(), ml::StandardItemModel::getData(), getParent(), ml::StandardItemModel::getParent(), hasChildren(), ml::StandardItemModel::hasChildren(), ml::StandardItemModel::insertItems(), ModelIndex, notifyItemChanged(), ml::StandardItemModel::notifyItemChildrenRequest(), notifyItemsInserted(), notifyItemsRemoved(), rawSetData(), ml::StandardItemModel::rawSetData(), ml::StandardItemModel::removeItems(), and setData().