13 #ifndef ML_ITEM_MODEL_ITEM_FILTER_H
14 #define ML_ITEM_MODEL_ITEM_FILTER_H
23 #include <ThirdPartyWarningsDisable.h>
24 #include <boost/unordered_map.hpp>
25 #include <ThirdPartyWarningsRestore.h>
86 void* skipListener =
nullptr)
override;
88 int attributeIndex,
const Variant& data,
89 void* skipListener =
nullptr)
override;
91 int attributeIndex,
const std::vector<Variant>& data,
92 void* skipListener =
nullptr)
override;
102 virtual bool itemVisible(
const ModelIndex& sourceItem);
106 bool refilterItem(
const ModelIndex& sourceItem);
109 unsigned int getTargetPos(
const ModelIndex& sourceParent,
unsigned int sourcePos);
118 typedef std::vector<unsigned int> MappingVector;
119 typedef boost::unordered_map<size_t, MappingVector*> MappingTable;
123 MappingVector* getMappingVector(
const ModelIndex& index);
126 MappingVector* getFilledMappingVector(
const ModelIndex& index);
129 void dropMappingVector(
const ModelIndex& sourceParent, MappingVector* v);
135 MappingVector* _topLevelMapping;
141 inline size_t mappingKey(
const ModelIndex& index)
147 inline bool hasMapping(
const ModelIndex& index)
149 return _items.find(mappingKey(index)) != _items.end();
153 void* _listenerToSkipForDataChange;
#define MLITEMMODEL_EXPORT
defined Header file mlItemModelSystem.h
This event tells us that the children of the item have changed completely (for an invalid ModelIndex ...
virtual bool filterItem(const ModelIndex &sourceItem)=0
Return true if the item from the source model should be in the result (directly matches)
std::string getAttributeName(int index) const override
Get name of n-th attribute. Must be overridden.
@ DirectMatchOrHasChildren
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.
int getAttributeCount() const override
attribute discovery, overridden to pass on requests
int getAttributeIndex(const std::string &name) override
Get index of attribute with the given name.
Variant getAttributeDefault(int index) const override
Return default value of n-th attribute.
unsigned int getChildCount(const ModelIndex &parent) override
Get number of children of the given item, an invalid index means number of top-level items.
bool hasChildren(const ModelIndex &parent) override
Or rather mightHaveChildren.
Variant getData(const ModelIndex &item, int attributeIndex) override
data access, overridden to apply filter mapping
ItemModelItemFilter(AbstractItemModelPtr sourceModel, FilterMode filterMode=DirectMatch)
ModelIndex getParent(const ModelIndex &child) override
Get parent of an item.
bool isFlat() const override
item traversal interface, overridden for filtering
virtual bool isFilteredAttribute(int attributeIndex) const
Returns if an attribute is involved in the filtering, returns true by default (this is for optimizati...
bool bulkSetData(const std::vector< ModelIndex > &items, int attributeIndex, const Variant &data, void *skipListener=nullptr) override
bulkSetData will be used by views to set selection state to an attribute, so that we only get a singl...
~ItemModelItemFilter() override
bool setData(const ModelIndex &item, int attributeIndex, const Variant &data, void *skipListener=nullptr) override
Update a single attribute on a single item.
ModelIndex getChild(const ModelIndex &parent, unsigned int index) override
Get n-th child of an item (or n-th top-level item if parent index is invalid).
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;...
This event informs about attributes that have changed their values.
This event informs about inserted items.
This event informs about removed items.
This class serves as an index into an AbstractItemModel.
size_t userID() const
access the internal user value (same as user pointer)
The Variant class stores different data types.
#define ML_ABSTRACT_CLASS_HEADER(className)
Same like ML_ABSTRACT_CLASS_HEADER_EXPORTED with a non existing export symbol.
#define ML_REFCOUNTED_PTR(CLASSNAME)
Macro that defines convenience Ptr/ConstPtr typedefs to be used instead of intrusive_ptr templates.