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;
64 int hasChildrenAttribute = -1,
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
PersistenceInterface
This enum describes the different persistence interfaces available.
ItemChildrenRequestEvent(const ModelIndex &parentIndexArg)
const ModelIndex & parentIndex() const
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
ModelIndex getChild(const ModelIndex &parent, unsigned int index) override
~StandardItemModel() override
virtual ModelIndex addItem(const ModelIndex &parent, const ItemData &)
bool rawSetData(const ModelIndex &item, int attributeIndex, const Variant &data) override
virtual int getChildPosition(const ModelIndex &child)
void readFrom(AbstractPersistenceInputStream *stream, int version) override
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)
ModelIndex getParent(const ModelIndex &child) override
StandardItemModel(const AttributeVector &attributes, int hasChildrenAttribute=-1, bool flat=false)
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
Variant getAttributeDefault(int index) const override
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
bool hasChildren(const ModelIndex &parent) override
Variant getData(const ModelIndex &item, int attributeIndex) override
Data access.
#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)
Attribute(const std::string &nameArg, const Variant &defaultValueArg=Variant())
std::string name
The name of the attribute.
Variant defaultValue
Default value of the attribute.