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;
73 bool isFlat()
const override {
return _isFlat; }
122 ItemEntry(ItemEntry*
aParent =
nullptr);
135 std::vector<ItemEntry*> children;
140 ItemEntry* indexToItem(
const ModelIndex& index);
143 AttributeVector _attributes;
146 ItemEntry* _rootItem;
152 ItemEntry* _incompleteParent;
156 int _hasChildrenAttribute;
183 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)
remove items
unsigned int getChildCount(const ModelIndex &parent) override
Get 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
Get 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)
get index position of child relative to its parent
void readFrom(AbstractPersistenceInputStream *stream, int version) override
Read the objects state from the data stream object.
bool isFlat() const override
overridden methods
virtual void clear()
clear the complete model
int getAttributeCount() const override
attribute discovery
virtual void insertItems(const ModelIndex &parent, unsigned int position, const ItemDataVector &items)
insert new items; this doesn't generate a insert notification during handling of a ItemChildrenReques...
ModelIndex getParent(const ModelIndex &child) override
Get parent of an item.
StandardItemModel(const AttributeVector &attributes, int hasChildrenAttribute=-1, bool flat=false)
Create new model with given attributes (and defaults); The second argument gives an attribute that sh...
std::vector< Attribute > AttributeVector
Vector of attributes.
StandardItemModel()
Create model without attributes.
std::string getAttributeName(int index) const override
Get name of n-th attribute. Must be overridden.
bool implementsPersistence(PersistenceInterface iface) const override
Persistence interface.
Variant getAttributeDefault(int index) const override
Return 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
Write 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
Name of the attribute.
Variant defaultValue
Default value of the attribute.