13#ifndef ML_STANDARD_ITEM_MODEL_H
14#define ML_STANDARD_ITEM_MODEL_H
22#include <boost/unordered_map.hpp>
50 typedef boost::unordered_map<int, Variant>
ItemData;
71 bool isFlat()
const override {
return _isFlat; }
125 ItemEntry(ItemEntry*
aParent =
nullptr);
138 std::vector<ItemEntry*> children;
143 ItemEntry* indexToItem(
const ModelIndex& index);
146 AttributeVector _attributes;
149 ItemEntry* _rootItem;
155 ItemEntry* _incompleteParent;
159 int _hasChildrenAttribute;
186 ModelIndex _parentIndex;
#define MLITEMMODEL_EXPORT
defined Header file mlItemModelSystem.h
This class represents an abstract hierarchical item model where the items have named attributes which...
Class for writing object data to a stream.
PersistenceInterface
This enum describes the different persistence interfaces available.
This BaseEvent informs that the children of an item are requested for the first time.
ItemChildrenRequestEvent(const ModelIndex &parentIndexArg)
const ModelIndex & parentIndex() const
This intermediate class only exists to conveniently get the source() as the model() from an event.
This class serves as an index into an AbstractItemModel.
This could be the interface for a standard item model.
std::vector< ItemData > ItemDataVector
Vector of item data.
virtual void removeItems(const ModelIndex &parent, unsigned int position, unsigned int numItems)
Removes items.
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.
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).
~StandardItemModel() override
virtual ModelIndex addItem(const ModelIndex &parent, const ItemData &)
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;...
virtual int getChildPosition(const ModelIndex &child)
Returns the index position of child relative to its parent.
void readFrom(AbstractPersistenceInputStream *stream, int version) override
Reads the objects state from the data stream object.
bool isFlat() const override
Overridden methods.
virtual void clear()
Clears the entire model.
int getAttributeCount() const override
Attribute discovery.
virtual void insertItems(const ModelIndex &parent, unsigned int position, const ItemDataVector &items)
Inserts new items; this does not generate a insert notification during handling of a ItemChildrenRequ...
ModelIndex getParent(const ModelIndex &child) override
Returns the parent of an item.
StandardItemModel(const AttributeVector &attributes, int hasChildrenAttribute=-1, bool flat=false)
Creates new model with given attributes (and defaults).
std::vector< Attribute > AttributeVector
Vector of attributes.
StandardItemModel()
Creates a model without attributes.
std::string getAttributeName(int index) const override
Returns the name of n-th attribute. Must be overridden.
bool implementsPersistence(PersistenceInterface iface) const override
Persistence interface.
Variant getAttributeDefault(int index) const override
Returns the default value of n-th attribute.
void notifyItemChildrenRequest(const ModelIndex &parent)
boost::unordered_map< int, Variant > ItemData
Item data, each attribute is specified via its int identifier and its variant value.
void writeTo(AbstractPersistenceOutputStream *stream) const override
Writes the objects state to the data stream object.
bool hasChildren(const ModelIndex &parent) override
Or rather mightHaveChildren.
Variant getData(const ModelIndex &item, int attributeIndex) override
Data access.
The Variant class stores different data types.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
#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)
Same like ML_CLASS_HEADER_EXPORTED with a non-existing export symbol.
Defines the name of an attribute and its default value.
Attribute(const std::string &nameArg, const Variant &defaultValueArg=Variant())
std::string name
The name of the attribute.
Variant defaultValue
Default value of the attribute.