42 std::unique_ptr<SessionItemData>
m_data;
43 std::unique_ptr<SessionItemTags>
m_tags;
55 bool result = m_data->setData(variant, role);
56 if (result && m_model)
57 m_model->mapper()->callOnDataChange(m_self, role);
72 p_impl->m_mapper->callOnItemDestroy();
75 p_impl->m_model->unregisterFromPool(
this);
82 return p_impl->m_modelType;
133 return p_impl->m_data->hasData(role);
140 return p_impl->m_data.get();
154 return static_cast<int>(
children().size());
161 return p_impl->m_tags->allitems();
168 return p_impl->m_tags->itemCount(tag);
175 return p_impl->m_tags->getItem({tag, row});
182 return p_impl->m_tags->getItems(tag);
197 return p_impl->m_tags.get();
204 p_impl->m_tags->registerTag(tagInfo, set_as_default);
221 throw std::runtime_error(
"SessionItem::insertItem() -> Invalid item.");
224 throw std::runtime_error(
"SessionItem::insertItem() -> Existing parent.");
227 throw std::runtime_error(
"SessionItem::insertItem() -> Existing model.");
229 auto result =
p_impl->m_tags->insertItem(
item, tagrow);
231 item->setParent(
this);
237 p_impl->m_model->mapper()->callOnItemInserted(
this, actual_tagrow);
248 if (!
p_impl->m_tags->canTakeItem(tagrow))
252 p_impl->m_model->mapper()->callOnItemAboutToBeRemoved(
this, tagrow);
254 auto result =
p_impl->m_tags->takeItem(tagrow);
255 result->setParent(
nullptr);
256 result->setModel(
nullptr);
259 p_impl->m_model->mapper()->callOnItemRemoved(
this, tagrow);
336 return act_through_model ?
model()->
setData(
this, value, role)
337 :
p_impl->do_setData(value, role);
345 return p_impl->m_data->data(role);
356 p_impl->m_model->unregisterFromPool(
this);
361 p_impl->m_model->registerInPool(
this);
364 child->setModel(
model);
369 int flags = appearance(*
this);
386 p_impl->m_mapper = std::make_unique<ItemMapper>(
this);
387 return p_impl->m_mapper.get();
391 std::unique_ptr<SessionItemTags> tags)
394 p_impl->m_tags = std::move(tags);
Provides notifications on various changes for a specific item.
Handles data roles for SessionItem.
The main object representing an editable/displayable/serializable entity.
SessionItemTags * itemTags()
Returns pointer to internal collection of tag-registered items (non-const version).
std::unique_ptr< SessionItemImpl > p_impl
std::string identifier() const
Returns unique identifier.
int itemCount(const std::string &tag) const
Returns number of items in given tag.
TagRow tagRowOfItem(const SessionItem *item) const
Returns pair of tag and row corresponding to given item.
std::vector< SessionItem * > getItems(const std::string &tag) const
Returns all children stored at given tag.
SessionItem * setEditable(bool value)
Sets editable flag to given value (fluent interface).
SessionItem * setEnabled(bool value)
Sets enabled flag to given value (fluent interface).
SessionItem * takeItem(const TagRow &tagrow)
Removes item from given row from given tag, returns it to the caller.
SessionItem * setToolTip(const std::string &tooltip)
Sets item tooltip (fluent interface).
SessionItem * getItem(const std::string &tag, int row=0) const
Returns item at given row of given tag.
bool hasData(int role=ItemDataRole::DATA) const
Returns true if item has data on board with given role.
SessionItem(model_type modelType=Constants::BaseType)
void setDataAndTags(std::unique_ptr< SessionItemData > data, std::unique_ptr< SessionItemTags > tags)
std::string editorType() const
Returns editor type.
bool isEnabled() const
Returns true if this item has enabled flag set.
void setAppearanceFlag(int flag, bool value)
void registerTag(const TagInfo &tagInfo, bool set_as_default=false)
Registers tag to hold items under given name.
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
std::string toolTip() const
Returns item tooltip, if exists.
bool isEditable() const
Returns true if this item has editable flag set.
SessionItem * setEditorType(const std::string &editor_type)
Sets editor type (fluent interface).
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.
bool set_data_internal(const Variant &value, int role, bool direct)
Sets the data for given role. Method invented to hide implementaiton details.
SessionModel * model() const
Returns the model to which given item belongs to.
int childrenCount() const
Returns total number of children in all tags.
void setParent(SessionItem *parent)
T data(int role=ItemDataRole::DATA) const
Returns data of given type T for given role.
ItemMapper * mapper()
Returns item mapper. Allows subscribing to various events happening to the item.
std::vector< SessionItem * > children() const
Returns vector of children formed from all chidlren from all tags.
SessionItemData * itemData()
Returns pointer to item's data container (non-const version).
virtual std::string displayName() const
Returns display name.
bool insertItem(SessionItem *item, const TagRow &tagrow)
Insert item into given tag under the given row.
TagRow tagRow() const
Returns TagRow of this item under which it is accessible through its parent.
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
Variant data_internal(int role) const
Returns data for given role.
virtual SessionItem * setDisplayName(const std::string &name)
Sets display name (fluent interface).
model_type modelType() const
Returns item's model type.
void setModel(SessionModel *model)
Main class to hold hierarchy of SessionItem objects.
bool setData(SessionItem *item, const Variant &value, int role)
Sets the data for given item.
UndoStackInterface * undoStack() const
Returns command stack to perform undo/redo.
Holds info about single tag for SessionItem.
Aggregate to hold (tag, row) information for SessionModel.
static identifier_type generate()
const int TOOLTIP
tooltip for item's data
const int EDITORTYPE
type of custom editor for the data role
const int APPEARANCE
appearance flag
const int DISPLAY
display name
const int IDENTIFIER
unique identifier
materialitems.h Collection of materials to populate MaterialModel.
QString const & name(EShape k)
bool do_setData(const Variant &variant, int role)
std::unique_ptr< SessionItemTags > m_tags
SessionItemImpl(SessionItem *this_item)
std::unique_ptr< SessionItemData > m_data
std::unique_ptr< ItemMapper > m_mapper