13#ifndef ML_ABSTRACT_ITEM_MODEL_H
14#define ML_ABSTRACT_ITEM_MODEL_H
34class AbstractItemModel;
55 inline bool isValid()
const {
return _model !=
nullptr; }
99 virtual bool isFlat()
const {
return false; }
153 void* skipListener =
nullptr);
159 int attributeIndex,
const Variant& data,
160 void* skipListener =
nullptr);
166 int attributeIndex,
const std::vector<Variant>& data,
167 void* skipListener =
nullptr);
202 void* skipListener =
nullptr);
210 void* skipListener =
nullptr);
218 void* skipListener =
nullptr);
226 const std::vector<int>& attributeIndices,
227 void* skipListener =
nullptr);
255 bool after()
const {
return _after; }
272 unsigned int position()
const {
return _position; }
280 ModelIndex _parentIndex;
281 unsigned int _position;
282 unsigned int _itemsInserted;
294 unsigned int position()
const {
return _position; }
302 ModelIndex _parentIndex;
303 unsigned int _position;
304 unsigned int _itemsRemoved;
335 const std::vector<ModelIndex>&
itemIndices()
const {
return _itemIndices; }
343 std::vector<ModelIndex> _itemIndices;
344 std::vector<int> _attributeIndices;
#define MLITEMMODEL_EXPORT
defined Header file mlItemModelSystem.h
virtual void notifyItemsInserted(const ModelIndex &parent, unsigned int childIndex, unsigned int itemsInserted, bool after, void *skipListener=nullptr)
virtual bool setData(const ModelIndex &item, int attributeIndex, const Variant &data, void *skipListener=nullptr)
virtual bool rawSetData(const ModelIndex &item, int attributeIndex, const Variant &data)=0
virtual ModelIndex getParent(const ModelIndex &child)=0
virtual void notifyItemsRemoved(const ModelIndex &parent, unsigned int childIndex, unsigned int itemsRemoved, bool after, void *skipListener=nullptr)
virtual void notifyItemChanged(const ModelIndex &item, bool after, void *skipListener=nullptr)
change notifications
virtual std::string getAttributeName(int index) const =0
Returns the name of n-th attribute. Must be overridden.
virtual int getAttributeIndex(const std::string &name)
virtual void incItemRefCount(void *)
Implement this if the pointer in the model indices needs explicit reference counting.
virtual int getAttributeCount() const =0
Attribute discovery.
virtual Variant getAttributeDefault(int index) const
virtual bool isFlat() const
item traversal interface
virtual Variant getData(const ModelIndex &item, int attributeIndex)=0
Data access.
virtual unsigned int getChildCount(const ModelIndex &parent)=0
ModelIndex createIndex(size_t data)
ModelIndex createIndex(void *data)
virtual ModelIndex getChild(const ModelIndex &parent, unsigned int index)=0
virtual bool bulkSetData(const std::vector< ModelIndex > &items, int attributeIndex, const Variant &data, void *skipListener=nullptr)
friend class ItemModelProxy
virtual void notifyItemsDataChanged(const std::vector< ModelIndex > &items, const std::vector< int > &attributeIndices, void *skipListener=nullptr)
virtual bool hasChildren(const ModelIndex &parent)
virtual void decItemRefCount(void *)
virtual bool bulkSetData(const std::vector< ModelIndex > &items, int attributeIndex, const std::vector< Variant > &data, void *skipListener=nullptr)
EventSource * source() const
Returns the Base object emitting this event.
const ModelIndex & index() const
ItemChangedEvent(const ModelIndex &index, bool after)
AbstractItemModel * model() const
This event informs about attributes that have changed their values.
const std::vector< ModelIndex > & itemIndices() const
const std::vector< int > & attributeIndices() const
ItemsDataChangedEvent(const std::vector< ModelIndex > &itemIndices, const std::vector< int > &attributeIndices)
This event informs about inserted items.
unsigned int position() const
unsigned int itemsInserted() const
ItemsInsertedEvent(const ModelIndex &parentIndex, unsigned int position, unsigned int itemsInserted, bool after)
const ModelIndex & parentIndex() const
This event informs about removed items.
const ModelIndex & parentIndex() const
ItemsRemovedEvent(const ModelIndex &parentIndex, unsigned int position, unsigned int itemsInserted, bool after)
unsigned int itemsRemoved() const
unsigned int position() const
AbstractItemModel * model() const
get the model of this index (this will be NULL for invalid indices)
friend class AbstractItemModel
bool isValid() const
return if this index is valid i.e. it points at an item in the model
size_t userID() const
access the internal user value (same as user pointer)
Variant getData(int attributeIndex) const
convenience method, this calls model()->getData(this, attributeIndex);
void * userPtr() const
access the internal user pointer (same as user value)
ModelIndex(const ModelIndex &other)
RefCountedBase()
Constructor.
TwoPhaseItemModelEvent(bool afterArg=false)
#define ML_ABSTRACT_CLASS_HEADER(className)
#define ML_REFCOUNTED_PTR(CLASSNAME)
Macro that defines convenience Ptr/ConstPtr typedefs to be used instead of intrusive_ptr templates.
#define ML_CLASS_HEADER(className)