MeVisLab Toolbox Reference
ml::ItemModelItemFilter Class Referenceabstract

#include <mlItemModelItemFilter.h>

Inheritance diagram for ml::ItemModelItemFilter:
ml::ItemModelProxy ml::AbstractItemModel ml::RefCountedBase ml::EventSource ml::Base

Public Types

enum  FilterMode { DirectMatch , DirectMatchOrHasChildren , CheckRecursively }
 
- Public Types inherited from ml::Base
enum  PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream }
 This enum describes the different persistence interfaces available. More...
 

Public Member Functions

 ItemModelItemFilter (AbstractItemModelPtr sourceModel, FilterMode filterMode=DirectMatch)
 
 ~ItemModelItemFilter () override
 
bool isFlat () const override
 Item traversal interface, overridden for filtering. More...
 
bool hasChildren (const ModelIndex &parent) override
 Or rather mightHaveChildren. More...
 
unsigned int getChildCount (const ModelIndex &parent) override
 Returns the number of children of the given item, an invalid index means number of top-level items. More...
 
ModelIndex getChild (const ModelIndex &parent, unsigned int index) override
 Returns the n-th child of an item (or n-th top-level item if parent index is invalid). More...
 
ModelIndex getParent (const ModelIndex &child) override
 Returns the parent of an item. More...
 
int getAttributeCount () const override
 Attribute discovery, overridden to pass on requests. More...
 
std::string getAttributeName (int index) const override
 Returns the name of n-th attribute. Must be overridden. More...
 
Variant getAttributeDefault (int index) const override
 Returns the default value of n-th attribute. More...
 
int getAttributeIndex (const std::string &name) override
 Returns the index of attribute with the given name. More...
 
Variant getData (const ModelIndex &item, int attributeIndex) override
 Data access, overridden to apply filter mapping. More...
 
bool setData (const ModelIndex &item, int attributeIndex, const Variant &data, void *skipListener=nullptr) override
 Updates a single attribute on a single item. More...
 
bool bulkSetData (const std::vector< ModelIndex > &items, int attributeIndex, const Variant &data, void *skipListener=nullptr) override
 This method will be used by views to set selection state to an attribute, so that we only get a single update notification. More...
 
bool bulkSetData (const std::vector< ModelIndex > &items, int attributeIndex, const std::vector< Variant > &data, void *skipListener=nullptr) override
 This method can be used to update whole columns with varying data. More...
 
bool rawSetData (const ModelIndex &item, int attributeIndex, const Variant &data) override
 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. More...
 
- Public Member Functions inherited from ml::ItemModelProxy
 ItemModelProxy (AbstractItemModelPtr sourceModel)
 
 ~ItemModelProxy () override
 
AbstractItemModelPtr sourceModel () const
 
- Public Member Functions inherited from ml::RefCountedBase
 RefCountedBase ()
 Constructor. More...
 
 RefCountedBase (const RefCountedBase &)
 Explicit copy constructor. More...
 
virtual void incRefCount () const
 Increases the reference count. More...
 
virtual void decRefCount () const
 Decreases the reference count (object will be deleted if the reference count is decremented to 0). More...
 
bool isRefCountedBase () const override
 Returns whether the instance is derived from RefCountedBase. More...
 
- Public Member Functions inherited from ml::EventSource
 EventSource ()
 
 EventSource (const EventSource &evSource)
 
 ~EventSource () override
 
void addEventListener (BaseEventCallback *cb, void *userData)
 Adds event listener callback to this Base object. More...
 
void removeEventListener (BaseEventCallback *cb, void *userData)
 Removes event listener callback from this Base object. More...
 
bool hasEventListeners () const
 Checks whether any event listeners have been added to this Base object; this can be used to skip the sendEvent call and the potentially expensive building of the event object altogether. More...
 
- Public Member Functions inherited from ml::Base
 Base ()
 Constructor. More...
 
virtual ~Base ()
 Destructor. More...
 
virtual BasedeepCopy () const
 Creates a deep copy of the given object. More...
 
bool isOfAllowedType (const std::vector< const RuntimeType * > &types) const
 Checks whether this object's type is equal to or derived from one of the types given in the argument. More...
 
virtual std::string detailString () const
 Returns a string describing this object. More...
 
virtual bool implementsPersistence (PersistenceInterface) const
 Override this method to declare which persistence interfaces are implemented by your derived class. More...
 
virtual std::string persistentState () const
 Returns a string describing the object's internal state. More...
 
virtual void setPersistentState (const std::string &state)
 Restores the object's internal state from a string that had been previously generated using persistentState(). More...
 
virtual void addStateToTree (TreeNode *) const
 Attaches the object state as children of the given parent node. More...
 
virtual void readStateFromTree (TreeNode *)
 Reads the object state from the children of the given parent node. More...
 
virtual void writeTo (AbstractPersistenceOutputStream *) const
 Writes the objects state to the data stream object. More...
 
virtual void readFrom (AbstractPersistenceInputStream *, int)
 Reads the objects state from the data stream object. More...
 

Protected Member Functions

virtual bool isFilteredAttribute (int attributeIndex) const
 Returns Whther an attribute is involved in the filtering, returns true by default. More...
 
virtual bool filterItem (const ModelIndex &sourceItem)=0
 Returns true if the item from the source model should be in the result (i.e., it directly matches). More...
 
- Protected Member Functions inherited from ml::ItemModelProxy
ModelIndex convertToSource (const ModelIndex &index)
 
ModelIndex convertFromSource (const ModelIndex &index)
 
void incItemRefCount (void *p) override
 Propagate to source model. More...
 
void decItemRefCount (void *p) override
 
- Protected Member Functions inherited from ml::AbstractItemModel
 AbstractItemModel ()
 
ModelIndex createIndex (void *data)
 
ModelIndex createIndex (size_t data)
 
virtual void notifyItemChanged (const ModelIndex &item, bool after, void *skipListener=nullptr)
 change notifications More...
 
virtual void notifyItemsInserted (const ModelIndex &parent, unsigned int childIndex, unsigned int itemsInserted, bool after, void *skipListener=nullptr)
 Notifies listeners that an item gets/got additional children. More...
 
virtual void notifyItemsRemoved (const ModelIndex &parent, unsigned int childIndex, unsigned int itemsRemoved, bool after, void *skipListener=nullptr)
 Notifies listeners that an item loses/lost additional children. More...
 
virtual void notifyItemsDataChanged (const std::vector< ModelIndex > &items, const std::vector< int > &attributeIndices, void *skipListener=nullptr)
 Notifies listeners that attributes have changed on the given items. More...
 
- Protected Member Functions inherited from ml::RefCountedBase
 ~RefCountedBase () override
 Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass.h. More...
 
- Protected Member Functions inherited from ml::EventSource
void sendEvent (BaseEvent *event, void *skipListener=nullptr)
 Macro for the declaration of the runtime type system methods, defined in mlRuntimeSubClass.h. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ml::RefCountedBase
static void updateReferenceCountingIfSupported (Base *oldValue, Base *newValue, bool &isRefCountedBase)
 Helper method that handles incrementing/decrementing of the reference count if base instances support it. More...
 
- Protected Attributes inherited from ml::RefCountedBase
std::atomic_int_least32_t _refCount
 Reference count. More...
 

Detailed Description

Definition at line 31 of file mlItemModelItemFilter.h.

Member Enumeration Documentation

◆ FilterMode

Enumerator
DirectMatch 
DirectMatchOrHasChildren 
CheckRecursively 

Definition at line 34 of file mlItemModelItemFilter.h.

Constructor & Destructor Documentation

◆ ItemModelItemFilter()

ml::ItemModelItemFilter::ItemModelItemFilter ( AbstractItemModelPtr  sourceModel,
FilterMode  filterMode = DirectMatch 
)

◆ ~ItemModelItemFilter()

ml::ItemModelItemFilter::~ItemModelItemFilter ( )
override

Member Function Documentation

◆ bulkSetData() [1/2]

bool ml::ItemModelItemFilter::bulkSetData ( const std::vector< ModelIndex > &  items,
int  attributeIndex,
const std::vector< Variant > &  data,
void *  skipListener = nullptr 
)
overridevirtual

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 from ml::AbstractItemModel.

◆ bulkSetData() [2/2]

bool ml::ItemModelItemFilter::bulkSetData ( const std::vector< ModelIndex > &  items,
int  attributeIndex,
const Variant data,
void *  skipListener = nullptr 
)
overridevirtual

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 from ml::AbstractItemModel.

◆ filterItem()

virtual bool ml::ItemModelItemFilter::filterItem ( const ModelIndex sourceItem)
protectedpure virtual

Returns true if the item from the source model should be in the result (i.e., it directly matches).

◆ getAttributeCount()

int ml::ItemModelItemFilter::getAttributeCount ( ) const
overridevirtual

Attribute discovery, overridden to pass on requests.

Returns the number of defined attributes for this model. Must be overridden.

Implements ml::AbstractItemModel.

◆ getAttributeDefault()

Variant ml::ItemModelItemFilter::getAttributeDefault ( int  index) const
overridevirtual

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 from ml::AbstractItemModel.

◆ getAttributeIndex()

int ml::ItemModelItemFilter::getAttributeIndex ( const std::string &  name)
overridevirtual

Returns the index of attribute with the given name.

Returns -1 if the attribute name does not exist in the model.

Reimplemented from ml::AbstractItemModel.

◆ getAttributeName()

std::string ml::ItemModelItemFilter::getAttributeName ( int  index) const
overridevirtual

Returns the name of n-th attribute. Must be overridden.

Implements ml::AbstractItemModel.

◆ getChild()

ModelIndex ml::ItemModelItemFilter::getChild ( const ModelIndex parent,
unsigned int  index 
)
overridevirtual

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.

Implements ml::AbstractItemModel.

◆ getChildCount()

unsigned int ml::ItemModelItemFilter::getChildCount ( const ModelIndex parent)
overridevirtual

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.

Implements ml::AbstractItemModel.

◆ getData()

Variant ml::ItemModelItemFilter::getData ( const ModelIndex item,
int  attributeIndex 
)
overridevirtual

Data access, overridden to apply filter mapping.

Implements ml::AbstractItemModel.

◆ getParent()

ModelIndex ml::ItemModelItemFilter::getParent ( const ModelIndex child)
overridevirtual

Returns the parent of an item.

Will return invalid index for top-level items. Must be overridden.

Implements ml::AbstractItemModel.

◆ hasChildren()

bool ml::ItemModelItemFilter::hasChildren ( const ModelIndex parent)
overridevirtual

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 from ml::AbstractItemModel.

◆ isFilteredAttribute()

virtual bool ml::ItemModelItemFilter::isFilteredAttribute ( int  attributeIndex) const
protectedvirtual

Returns Whther an attribute is involved in the filtering, returns true by default.

This method is for optimization.

◆ isFlat()

bool ml::ItemModelItemFilter::isFlat ( ) const
overridevirtual

Item traversal interface, overridden for filtering.

Reimplemented from ml::AbstractItemModel.

◆ rawSetData()

bool ml::ItemModelItemFilter::rawSetData ( const ModelIndex item,
int  attributeIndex,
const Variant data 
)
overridevirtual

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.

Implements ml::AbstractItemModel.

◆ setData()

bool ml::ItemModelItemFilter::setData ( const ModelIndex item,
int  attributeIndex,
const Variant data,
void *  skipListener = nullptr 
)
overridevirtual

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 from ml::AbstractItemModel.


The documentation for this class was generated from the following file: