15 #ifndef BORNAGAIN_GUI_MODEL_BASEITEM_MODELMAPPER_H
16 #define BORNAGAIN_GUI_MODEL_BASEITEM_MODELMAPPER_H
18 #include <QModelIndex>
32 void setOnValueChange(std::function<
void(
void)> f,
const void* caller =
nullptr);
36 const void* caller =
nullptr);
39 const void* caller =
nullptr);
54 void onDataChanged(
const QModelIndex& topLeft,
const QModelIndex& bottomRight,
55 const QVector<int>& roles = {});
57 void onRowsInserted(
const QModelIndex& parent,
int first,
int last);
61 void onRowRemoved(
const QModelIndex& parent,
int first,
int last);
83 using call_t = std::pair<std::function<void(
void)>,
const void*>;
84 using call_str_t = std::pair<std::function<void(QString)>,
const void*>;
100 v.erase(std::remove_if(
102 [caller](
typename U::value_type
const& x) ->
bool { return (x.second == caller); }),
ModelMapper(QObject *parent=nullptr)
void unsubscribe(const void *caller)
Cancels all subscriptions of given caller.
void setOnAboutToRemoveChild(std::function< void(SessionItem *)> f, const void *caller=nullptr)
void onBeginRemoveRows(const QModelIndex &parent, int first, int last)
void callOnPropertyChange(const QString &name)
void onRowRemoved(const QModelIndex &parent, int first, int last)
void callOnChildPropertyChange(SessionItem *item, const QString &name)
std::pair< std::function< void(SessionItem *, QString)>, const void * > call_item_str_t
void callOnItemDestroy()
Notifies subscribers if an item owning given mapper is about to be destroyed.
void setOnItemDestroy(std::function< void(SessionItem *)> f, const void *caller=nullptr)
void setActive(bool state)
void clean_container(U &v, const void *caller)
removes all callbacks related to given caller
std::pair< std::function< void(SessionItem *)>, const void * > call_item_t
void callOnChildrenChange(SessionItem *item)
void setOnChildrenChange(std::function< void(SessionItem *)> f, const void *caller=nullptr)
Calls back when number of children has changed, reports newChild. newChild == nullptr denotes the cas...
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles={})
std::vector< call_item_t > m_onChildrenChange
std::vector< call_t > m_onValueChange
QModelIndex m_aboutToDelete
void setItem(SessionItem *item)
void setModel(SessionModel *model)
std::pair< std::function< void(QString)>, const void * > call_str_t
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
std::pair< std::function< void(void)>, const void * > call_t
std::vector< call_item_str_t > m_onPropertyChange
int nestlingDepth(SessionItem *item, int level=0)
std::vector< call_item_str_t > m_onChildPropertyChange
void callOnAboutToRemoveChild(SessionItem *item)
std::vector< call_item_t > m_onItemDestroy
void onRowsInserted(const QModelIndex &parent, int first, int last)
void setOnValueChange(std::function< void(void)> f, const void *caller=nullptr)
void setOnChildPropertyChange(std::function< void(SessionItem *, QString)> f, const void *caller=nullptr)
Calls back on child property change, report childItem and property name.
std::vector< call_item_t > m_onAboutToRemoveChild
Base class for a GUI data item.
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
QString const & name(EShape k)