75 if (
auto parent = item->
parent())
151 throw std::runtime_error(
"ItemMapper::ItemMapper() -> Not initialized item");
154 throw std::runtime_error(
"ItemMapper::ItemMapper() -> Item doesn't have model");
158 auto on_data_change = [
this](
auto item,
auto role) {
p_impl->processDataChange(item, role); };
161 auto on_item_inserted = [
this](
auto item,
auto tagrow) {
162 p_impl->processItemInserted(item, tagrow);
166 auto on_item_removed = [
this](
auto item,
auto tagrow) {
167 p_impl->processItemRemoved(item, tagrow);
171 auto on_about_to_remove_item = [
this](
auto item,
auto tagrow) {
172 p_impl->processAboutToRemoveItem(item, tagrow);
181 p_impl->m_on_item_destroy.connect(std::move(f), owner);
186 p_impl->m_on_data_change.connect(std::move(f), owner);
191 p_impl->m_on_property_change.connect(std::move(f), owner);
196 p_impl->m_on_child_property_change.connect(std::move(f), owner);
201 p_impl->m_on_item_inserted.connect(std::move(f), owner);
206 p_impl->m_on_item_removed.connect(std::move(f), owner);
211 p_impl->m_on_about_to_remove_item.connect(std::move(f), owner);
216 p_impl->unsubscribe(client);
Provides notifications on various changes for a specific item.
void setOnItemDestroy(Callbacks::item_t f, Callbacks::slot_t owner) override
void setActive(bool value)
Sets activity flag to given value. Will disable all callbacks if false.
void setOnItemRemoved(Callbacks::item_tagrow_t f, Callbacks::slot_t owner) override
Sets callback to be notified on child removal.
void callOnItemDestroy()
Calls all callbacks subscribed to "item is destroyed" event.
void setOnAboutToRemoveItem(Callbacks::item_tagrow_t f, Callbacks::slot_t owner) override
Sets callback to be notified when row is about to be removed.
ItemMapper(SessionItem *item)
void setOnItemInserted(Callbacks::item_tagrow_t f, Callbacks::slot_t owner) override
Sets callback to be notified on child insertion.
void unsubscribe(Callbacks::slot_t client) override
Removes given client from all subscriptions.
std::unique_ptr< ItemMapperImpl > p_impl
void setOnDataChange(Callbacks::item_int_t f, Callbacks::slot_t owner) override
Sets callback to be notified on item's data change.
void setOnPropertyChange(Callbacks::item_str_t f, Callbacks::slot_t owner) override
Sets callback to be notified on item's property change.
void setOnChildPropertyChange(Callbacks::item_str_t f, Callbacks::slot_t owner) override
Sets callback to be notified on item's children property change.
void setOnItemRemoved(Callbacks::item_tagrow_t f, Callbacks::slot_t client={}) override
Sets callback to be notified on item remove.
void setOnItemInserted(Callbacks::item_tagrow_t f, Callbacks::slot_t client={}) override
Sets callback to be notified on item insert.
void setOnAboutToRemoveItem(Callbacks::item_tagrow_t f, Callbacks::slot_t client={}) override
Sets callback to be notified when the item is about to be removed.
void setOnDataChange(Callbacks::item_int_t f, Callbacks::slot_t client={}) override
Sets callback to be notified on item's data change.
Templated class for all objects willing to listen for changes in concrete SessionModel.
The main object representing an editable/displayable/serializable entity.
TagRow tagRowOfItem(const SessionItem *item) const
Returns pair of tag and row corresponding to given item.
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.
SessionModel * model() const
Returns the model to which given item belongs to.
SessionItem * rootItem() const
Returns root item of the model.
void remove_client(U client)
Remove client from the list to call back.
Aggregate to hold (tag, row) information for SessionModel.
std::function< void(SessionItem *, std::string)> item_str_t
std::function< void(SessionItem *, TagRow)> item_tagrow_t
std::function< void(SessionItem *, int)> item_int_t
std::function< void(SessionItem *)> item_t
materialitems.h Collection of materials to populate MaterialModel.
void callOnItemInserted(SessionItem *parent, const TagRow &tagrow)
Notifies all callbacks subscribed to "on row inserted" event.
Signal< Callbacks::item_tagrow_t > m_on_about_to_remove_item
void callOnChildPropertyChange(SessionItem *item, const std::string &property_name)
Notifies all callbacks subscribed to "child property changed" event.
void processAboutToRemoveItem(SessionItem *parent, const TagRow &tagrow)
ItemMapper * m_itemMapper
void callOnDataChange(SessionItem *item, int role)
Notifies all callbacks subscribed to "item data is changed" event.
Signal< Callbacks::item_int_t > m_on_data_change
Signal< Callbacks::item_tagrow_t > m_on_item_removed
void callOnItemRemoved(SessionItem *parent, const TagRow &tagrow)
Notifies all callbacks subscribed to "on row removed" event.
Signal< Callbacks::item_str_t > m_on_child_property_change
Signal< Callbacks::item_t > m_on_item_destroy
int nestlingDepth(SessionItem *item, int level=0)
void callOnPropertyChange(SessionItem *item, const std::string &property_name)
Notifies all callbacks subscribed to "item property is changed" event.
Signal< Callbacks::item_str_t > m_on_property_change
void processDataChange(SessionItem *item, int role)
Processes signals from the model when item data changed.
Signal< Callbacks::item_tagrow_t > m_on_item_inserted
void unsubscribe(Callbacks::slot_t client)
void callOnAboutToRemoveItem(SessionItem *parent, const TagRow &tagrow)
Notifies all callbacks subscribed to "on row about to be removed".
ItemMapperImpl(ItemMapper *item_mapper)
void processItemInserted(SessionItem *parent, const TagRow &tagrow)
void processItemRemoved(SessionItem *parent, const TagRow &tagrow)