BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::SessionItem Class Reference

The main object representing an editable/displayable/serializable entity. More...

Inheritance diagram for ModelView::SessionItem:
[legend]

Public Member Functions

 SessionItem (const SessionItem &)=delete
 
 SessionItem (model_type modelType=Constants::BaseType)
 
virtual ~SessionItem ()
 
std::vector< SessionItem * > children () const
 Returns vector of children formed from all chidlren from all tags. More...
 
int childrenCount () const
 Returns total number of children in all tags. More...
 
template<typename T >
data (int role=ItemDataRole::DATA) const
 Returns data of given type T for given role. More...
 
virtual std::string displayName () const
 Returns display name. More...
 
std::string editorType () const
 Returns editor type. More...
 
SessionItemgetItem (const std::string &tag, int row=0) const
 Returns item at given row of given tag. More...
 
std::vector< SessionItem * > getItems (const std::string &tag) const
 Returns all children stored at given tag. More...
 
bool hasData (int role=ItemDataRole::DATA) const
 Returns true if item has data on board with given role. More...
 
std::string identifier () const
 Returns unique identifier. More...
 
bool insertItem (SessionItem *item, const TagRow &tagrow)
 Insert item into given tag under the given row. More...
 
bool isEditable () const
 Returns true if this item has editable flag set. More...
 
bool isEnabled () const
 Returns true if this item has enabled flag set. More...
 
template<typename T >
T * item (const std::string &tag) const
 Returns first item under given tag casted to a specified type. More...
 
int itemCount (const std::string &tag) const
 Returns number of items in given tag. More...
 
SessionItemDataitemData ()
 Returns pointer to item's data container (non-const version). More...
 
const SessionItemDataitemData () const
 Returns pointer to item's data container (const version). More...
 
template<typename T = SessionItem>
std::vector< T * > items (const std::string &tag) const
 Returns all items under given tag casted to specific type. More...
 
SessionItemTagsitemTags ()
 Returns pointer to internal collection of tag-registered items (non-const version). More...
 
const SessionItemTagsitemTags () const
 Returns pointer to internal collection of tag-registered items (const version). More...
 
ItemMappermapper ()
 Returns item mapper. Allows subscribing to various events happening to the item. More...
 
SessionModelmodel () const
 Returns the model to which given item belongs to. More...
 
model_type modelType () const
 Returns item's model type. More...
 
SessionItemoperator= (const SessionItem &)=delete
 
SessionItemparent () const
 Returns parent item. Will return nullptr if item doesn't have a parent. More...
 
template<typename T >
property (const std::string &tag) const
 Returns data stored in property item. More...
 
void registerTag (const TagInfo &tagInfo, bool set_as_default=false)
 Registers tag to hold items under given name. More...
 
template<typename T >
bool setData (const T &value, int role=ItemDataRole::DATA, bool direct=false)
 Sets data for a given role. More...
 
virtual SessionItemsetDisplayName (const std::string &name)
 Sets display name (fluent interface). More...
 
SessionItemsetEditable (bool value)
 Sets editable flag to given value (fluent interface). More...
 
SessionItemsetEditorType (const std::string &editor_type)
 Sets editor type (fluent interface). More...
 
SessionItemsetEnabled (bool value)
 Sets enabled flag to given value (fluent interface). More...
 
void setProperty (const std::string &tag, const char *value)
 Sets value to property item (specialized for special "const char *" case). More...
 
template<typename T >
void setProperty (const std::string &tag, const T &value)
 Sets value to property item. More...
 
SessionItemsetToolTip (const std::string &tooltip)
 Sets item tooltip (fluent interface). More...
 
TagRow tagRow () const
 Returns TagRow of this item under which it is accessible through its parent. More...
 
TagRow tagRowOfItem (const SessionItem *item) const
 Returns pair of tag and row corresponding to given item. More...
 
SessionItemtakeItem (const TagRow &tagrow)
 Removes item from given row from given tag, returns it to the caller. More...
 
std::string toolTip () const
 Returns item tooltip, if exists. More...
 

Private Member Functions

virtual void activate ()
 
Variant data_internal (int role) const
 Returns data for given role. More...
 
bool set_data_internal (const Variant &value, int role, bool direct)
 Sets the data for given role. Method invented to hide implementaiton details. More...
 
void setAppearanceFlag (int flag, bool value)
 
void setDataAndTags (std::unique_ptr< SessionItemData > data, std::unique_ptr< SessionItemTags > tags)
 
void setModel (SessionModel *model)
 
void setParent (SessionItem *parent)
 

Private Attributes

std::unique_ptr< SessionItemImpl > p_impl
 

Friends

class JsonItemConverter
 
class SessionModel
 

Detailed Description

The main object representing an editable/displayable/serializable entity.

Serves as a construction element (node) of SessionModel to represent all the data of GUI application.

Definition at line 38 of file sessionitem.h.

Constructor & Destructor Documentation

◆ SessionItem() [1/2]

SessionItem::SessionItem ( model_type  modelType = Constants::BaseType)
explicit

Definition at line 62 of file sessionitem.cpp.

62  : p_impl(std::make_unique<SessionItemImpl>(this))
63 {
64  p_impl->m_modelType = std::move(modelType);
66  setData(p_impl->m_modelType, ItemDataRole::DISPLAY);
67 }
std::unique_ptr< SessionItemImpl > p_impl
Definition: sessionitem.h:133
bool setData(const T &value, int role=ItemDataRole::DATA, bool direct=false)
Sets data for a given role.
Definition: sessionitem.h:141
model_type modelType() const
Returns item's model type.
Definition: sessionitem.cpp:80
static identifier_type generate()
const int DISPLAY
display name
Definition: mvvm_types.h:31
const int IDENTIFIER
unique identifier
Definition: mvvm_types.h:29

References ModelView::ItemDataRole::DISPLAY, ModelView::UniqueIdGenerator::generate(), ModelView::ItemDataRole::IDENTIFIER, modelType(), p_impl, and setData().

Here is the call graph for this function:

◆ ~SessionItem()

SessionItem::~SessionItem ( )
virtual

Definition at line 69 of file sessionitem.cpp.

70 {
71  if (p_impl->m_mapper)
72  p_impl->m_mapper->callOnItemDestroy();
73 
74  if (p_impl->m_model)
75  p_impl->m_model->unregisterFromPool(this);
76 }

References p_impl.

◆ SessionItem() [2/2]

ModelView::SessionItem::SessionItem ( const SessionItem )
delete

Member Function Documentation

◆ activate()

virtual void ModelView::SessionItem::activate ( )
inlineprivatevirtual

Reimplemented in ToyItems::LatticeItem, ModelView::VectorItem, and gui2::MultiLayerItem.

Definition at line 123 of file sessionitem.h.

123 {}

Referenced by ModelView::SessionModel::registerInPool().

◆ children()

◆ childrenCount()

int SessionItem::childrenCount ( ) const

Returns total number of children in all tags.

Definition at line 152 of file sessionitem.cpp.

153 {
154  return static_cast<int>(children().size());
155 }
std::vector< SessionItem * > children() const
Returns vector of children formed from all chidlren from all tags.

References children().

Referenced by gui2::SLDElementController::buildSLD(), ModelView::ContainerItem::empty(), gui2::SLDElementController::getIdentifierVector(), ModelView::ContainerItem::size(), and TEST_F().

Here is the call graph for this function:

◆ data()

template<typename T >
T SessionItem::data ( int  role = ItemDataRole::DATA) const
inline

Returns data of given type T for given role.

Definition at line 148 of file sessionitem.h.

149 {
150  return data_internal(role).value<T>();
151 }
Variant data_internal(int role) const
Returns data for given role.

References data_internal().

Referenced by ModelView::Utils::CheckStateRole(), ModelView::PointwiseAxisItem::create(), ModelView::ViewItem::ViewItemImpl::data(), ModelView::SessionModel::data(), ModelView::Utils::DecorationRole(), property(), ModelView::PointwiseAxisItem::range(), ModelView::Data2DItem::setContent(), setDataAndTags(), ModelView::PointwiseAxisItem::setParameters(), ModelView::Data1DItem::setValues(), and TEST_F().

Here is the call graph for this function:

◆ data_internal()

Variant SessionItem::data_internal ( int  role) const
private

Returns data for given role.

Method invented to hide implementaiton details and avoid placing sessionitemdata.h into 'sessionitem.h' header.

Definition at line 343 of file sessionitem.cpp.

344 {
345  return p_impl->m_data->data(role);
346 }

References p_impl.

Referenced by data().

◆ displayName()

std::string SessionItem::displayName ( ) const
virtual

Returns display name.

Reimplemented in ModelView::CompoundItem.

Definition at line 94 of file sessionitem.cpp.

95 {
96  return data<std::string>(ItemDataRole::DISPLAY);
97 }

References ModelView::ItemDataRole::DISPLAY.

Referenced by gui2::Utils::CreateProperty(), ModelView::CompoundItem::displayName(), and TEST_F().

◆ editorType()

std::string SessionItem::editorType ( ) const

Returns editor type.

Definition at line 314 of file sessionitem.cpp.

315 {
316  return hasData(ItemDataRole::EDITORTYPE) ? data<std::string>(ItemDataRole::EDITORTYPE)
317  : std::string();
318 }
bool hasData(int role=ItemDataRole::DATA) const
Returns true if item has data on board with given role.
const int EDITORTYPE
type of custom editor for the data role
Definition: mvvm_types.h:35
Definition: filesystem.h:81

References ModelView::ItemDataRole::EDITORTYPE, and hasData().

Referenced by ModelView::RoleDependentEditorFactory::createItemEditor(), and TEST_F().

Here is the call graph for this function:

◆ getItem()

◆ getItems()

std::vector< SessionItem * > SessionItem::getItems ( const std::string &  tag) const

Returns all children stored at given tag.

Definition at line 180 of file sessionitem.cpp.

181 {
182  return p_impl->m_tags->getItems(tag);
183 }

References p_impl.

Referenced by items(), and TEST_F().

◆ hasData()

bool SessionItem::hasData ( int  role = ItemDataRole::DATA) const

Returns true if item has data on board with given role.

Definition at line 131 of file sessionitem.cpp.

132 {
133  return p_impl->m_data->hasData(role);
134 }

References p_impl.

Referenced by editorType(), TEST_F(), toolTip(), and ModelView::Utils::ToolTipRole().

◆ identifier()

std::string SessionItem::identifier ( ) const

◆ insertItem()

bool SessionItem::insertItem ( SessionItem item,
const TagRow tagrow 
)

Insert item into given tag under the given row.

Definition at line 216 of file sessionitem.cpp.

217 {
218  // think of passing unique_ptr directly
219 
220  if (!item)
221  throw std::runtime_error("SessionItem::insertItem() -> Invalid item.");
222 
223  if (item->parent())
224  throw std::runtime_error("SessionItem::insertItem() -> Existing parent.");
225 
226  if (item->model())
227  throw std::runtime_error("SessionItem::insertItem() -> Existing model.");
228 
229  auto result = p_impl->m_tags->insertItem(item, tagrow);
230  if (result) {
231  item->setParent(this);
232  item->setModel(model());
233 
234  if (p_impl->m_model) {
235  // FIXME think of actual_tagrow removal if input tag,row will be always valid
236  auto actual_tagrow = tagRowOfItem(item);
237  p_impl->m_model->mapper()->callOnItemInserted(this, actual_tagrow);
238  }
239  }
240 
241  return result;
242 }
TagRow tagRowOfItem(const SessionItem *item) const
Returns pair of tag and row corresponding to given item.
SessionModel * model() const
Returns the model to which given item belongs to.
T * item(const std::string &tag) const
Returns first item under given tag casted to a specified type.
Definition: sessionitem.h:156

References item(), model(), p_impl, and tagRowOfItem().

Referenced by ModelView::CompoundItem::addProperty(), ModelView::GroupItem::init_group(), ModelView::Data2DItem::insert_axis(), ModelView::Data1DItem::setAxis(), and TEST_F().

Here is the call graph for this function:

◆ isEditable()

bool SessionItem::isEditable ( ) const

Returns true if this item has editable flag set.

The data value of an editable item normally can be changed when it appears in trees and tables.

Definition at line 267 of file sessionitem.cpp.

268 {
269  return appearance(*this) & Appearance::EDITABLE;
270 }

References ModelView::EDITABLE.

Referenced by TEST_F().

◆ isEnabled()

bool SessionItem::isEnabled ( ) const

Returns true if this item has enabled flag set.

Enabled items appear in normal color, disabled items are grayed out.

Definition at line 283 of file sessionitem.cpp.

284 {
285  return appearance(*this) & Appearance::ENABLED;
286 }

References ModelView::ENABLED.

Referenced by ModelView::PropertyFlatView::PropertyFlatViewImpl::create_label(), TEST_F(), and ModelView::Utils::TextColorRole().

◆ item()

template<typename T >
T * SessionItem::item ( const std::string &  tag) const
inline

Returns first item under given tag casted to a specified type.

Returns nullptr, if item doesn't exist. If item exists but can't be casted will throw.

Definition at line 156 of file sessionitem.h.

157 {
158  if (auto item = getItem(tag); item) {
159  T* tag_item = dynamic_cast<T*>(item);
160  if (!tag_item)
161  throw std::runtime_error("Can't cast an item to given type");
162  return tag_item;
163  }
164  return nullptr;
165 }
SessionItem * getItem(const std::string &tag, int row=0) const
Returns item at given row of given tag.

References getItem().

Referenced by ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::init_axis(), insertItem(), items(), gui2::Utils::SetDifference(), ModelView::GraphItem::setFromGraphItem(), ModelView::LinkedItem::setLink(), ModelView::ColorMapViewportPlotController::ColorMapViewportPlotControllerImpl::setup_components(), tagRowOfItem(), TEST_F(), gui2::SLDElementController::updateRoughnessFromView(), and gui2::JobModel::updateSpecularData().

Here is the call graph for this function:

◆ itemCount()

int SessionItem::itemCount ( const std::string &  tag) const

Returns number of items in given tag.

Definition at line 166 of file sessionitem.cpp.

167 {
168  return p_impl->m_tags->itemCount(tag);
169 }

References p_impl.

Referenced by ModelView::MoveItemCommand::MoveItemCommand(), ModelView::CommandService::copyItem(), ModelView::CommandService::insertNewItem(), ModelView::Utils::MoveDown(), and ModelView::CommandService::moveItem().

◆ itemData() [1/2]

SessionItemData * SessionItem::itemData ( )

Returns pointer to item's data container (non-const version).

Definition at line 145 of file sessionitem.cpp.

146 {
147  return const_cast<SessionItemData*>(static_cast<const SessionItem*>(this)->itemData());
148 }
Handles data roles for SessionItem.
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
SessionItemData * itemData()
Returns pointer to item's data container (non-const version).

Referenced by ModelView::JsonItemConverter::JsonItemConverterImpl::item_to_json(), ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item(), and TEST_F().

◆ itemData() [2/2]

const SessionItemData * SessionItem::itemData ( ) const

Returns pointer to item's data container (const version).

Definition at line 138 of file sessionitem.cpp.

139 {
140  return p_impl->m_data.get();
141 }

References p_impl.

◆ items()

template<typename T >
std::vector< T * > SessionItem::items ( const std::string &  tag) const

Returns all items under given tag casted to specific type.

Definition at line 169 of file sessionitem.h.

170 {
171  std::vector<T*> result;
172  for (auto item : getItems(tag))
173  if (auto casted = dynamic_cast<T*>(item); casted)
174  result.push_back(casted);
175  return result;
176 }
std::vector< SessionItem * > getItems(const std::string &tag) const
Returns all children stored at given tag.

References getItems(), and item().

Referenced by TEST_F().

Here is the call graph for this function:

◆ itemTags() [1/2]

SessionItemTags * SessionItem::itemTags ( )

Returns pointer to internal collection of tag-registered items (non-const version).

Definition at line 209 of file sessionitem.cpp.

210 {
211  return const_cast<SessionItemTags*>(static_cast<const SessionItem*>(this)->itemTags());
212 }
Collection of SessionItem's containers according to their tags.
SessionItemTags * itemTags()
Returns pointer to internal collection of tag-registered items (non-const version).

Referenced by ModelView::Utils::HasTag(), ModelView::Utils::IsSinglePropertyTag(), ModelView::JsonItemConverter::JsonItemConverterImpl::item_to_json(), ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item(), ModelView::Utils::RegisteredTags(), TEST(), and TEST_F().

◆ itemTags() [2/2]

const SessionItemTags * SessionItem::itemTags ( ) const

Returns pointer to internal collection of tag-registered items (const version).

Definition at line 195 of file sessionitem.cpp.

196 {
197  return p_impl->m_tags.get();
198 }

References p_impl.

◆ mapper()

ItemMapper * SessionItem::mapper ( )

Returns item mapper. Allows subscribing to various events happening to the item.

Definition at line 383 of file sessionitem.cpp.

384 {
385  if (!p_impl->m_mapper)
386  p_impl->m_mapper = std::make_unique<ItemMapper>(this);
387  return p_impl->m_mapper.get();
388 }

References p_impl.

Referenced by MockWidgetForItem::~MockWidgetForItem(), gui2::MultiLayerItem::activate(), ModelView::VectorItem::activate(), ToyItems::LatticeItem::activate(), gui2::LayerElementController::connectToModel(), gui2::LayerElementController::disconnectFormModel(), and MockWidgetForItem::setItem().

◆ model()

◆ modelType()

◆ operator=()

SessionItem& ModelView::SessionItem::operator= ( const SessionItem )
delete

◆ parent()

◆ property()

template<typename T >
T SessionItem::property ( const std::string &  tag) const
inline

Returns data stored in property item.

Property is single item registered under certain tag via CompoundItem::addProperty method.

Definition at line 181 of file sessionitem.h.

182 {
183  return getItem(tag)->data<T>();
184 }
T data(int role=ItemDataRole::DATA) const
Returns data of given type T for given role.
Definition: sessionitem.h:148

References data(), and getItem().

Referenced by ToyItems::LatticeItem::activate(), ModelView::CompoundItem::addProperty(), gui2::LayerElementController::firstSegmentHandleRect(), gui2::LayerElementController::leftHandleMoved(), gui2::LayerElementController::leftRoughnessHandleRect(), gui2::LayerElementController::leftRoughnessPath(), gui2::LayerElementController::rightHandleMoved(), gui2::LayerElementController::rightRoughnessHandleRect(), gui2::LayerElementController::rightRoughnessPath(), gui2::LayerElementController::secondSegmentHandleRect(), gui2::LayerElementController::setLayerAbove(), gui2::LayerElementController::setRoughnessInLimits(), gui2::LayerElementController::sideSegmentMoved(), gui2::LayerElementController::sideSegmentRect(), TEST_F(), gui2::LayerElementController::topSegmentRect(), ModelView::ColorMapPlotController::ColorMapPlotControllerImpl::update_gradient(), ModelView::PenController::PenControllerImpl::update_graph_from_item(), ModelView::ColorMapPlotController::ColorMapPlotControllerImpl::update_interpolation(), ModelView::AxisTitleController::AxisTitleControllerImpl::updateAxisFromItem(), ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateLowerRange(), gui2::LayerElementController::updateRoughness(), gui2::SLDElementController::updateToView(), and ModelView::ViewportAxisPlotController::AxesPlotControllerImpl::updateUpperRange().

Here is the call graph for this function:

◆ registerTag()

◆ set_data_internal()

bool SessionItem::set_data_internal ( const Variant value,
int  role,
bool  direct 
)
private

Sets the data for given role. Method invented to hide implementaiton details.

Definition at line 331 of file sessionitem.cpp.

332 {
333  // If model is present, and undo stack is enabled, will forward request to the model
334  // (unless user explicitely asks for direct processing via direct=true flag).
335  const bool act_through_model = !direct && model() && model()->undoStack();
336  return act_through_model ? model()->setData(this, value, role)
337  : p_impl->do_setData(value, role);
338 }
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.

References model(), p_impl, ModelView::SessionModel::setData(), and ModelView::SessionModel::undoStack().

Referenced by setData().

Here is the call graph for this function:

◆ setAppearanceFlag()

void SessionItem::setAppearanceFlag ( int  flag,
bool  value 
)
private

Definition at line 367 of file sessionitem.cpp.

368 {
369  int flags = appearance(*this);
370  if (value)
371  flags |= flag;
372  else
373  flags &= ~flag;
374 
375  // By setting data with internal method we are bypassing the model, and so undo/redo.
376  // So current convention is to not invoke undo when changing appearance properties.
377  // Shall we change it?
378  p_impl->do_setData(flags, ItemDataRole::APPEARANCE);
379 }
const int APPEARANCE
appearance flag
Definition: mvvm_types.h:32

References ModelView::ItemDataRole::APPEARANCE, and p_impl.

Referenced by setEditable(), and setEnabled().

◆ setData()

template<typename T >
bool SessionItem::setData ( const T &  value,
int  role = ItemDataRole::DATA,
bool  direct = false 
)
inline

Sets data for a given role.

When extra parameter direct is false (default case), will act through the model to register command in undo/redo framework (if enabled) and so allow later undo.

Definition at line 141 of file sessionitem.h.

142 {
143  return set_data_internal(Variant::fromValue(value), role, direct);
144 }
bool set_data_internal(const Variant &value, int role, bool direct)
Sets the data for given role. Method invented to hide implementaiton details.

References set_data_internal().

Referenced by gui2::CanvasItem::CanvasItem(), ModelView::GroupItem::GroupItem(), ModelView::LinkedItem::LinkedItem(), ModelView::PointwiseAxisItem::PointwiseAxisItem(), SessionItem(), ModelView::GroupItem::init_group(), ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item(), ModelView::Data2DItem::setContent(), ModelView::GroupItem::setCurrentIndex(), setDisplayName(), setEditorType(), ModelView::PropertyItem::setLimits(), ModelView::LinkedItem::setLink(), ModelView::PointwiseAxisItem::setParameters(), setProperty(), setToolTip(), TEST_F(), and ModelView::VectorItem::update_label().

Here is the call graph for this function:

◆ setDataAndTags()

void SessionItem::setDataAndTags ( std::unique_ptr< SessionItemData data,
std::unique_ptr< SessionItemTags tags 
)
private

Definition at line 390 of file sessionitem.cpp.

392 {
393  p_impl->m_data = std::move(data);
394  p_impl->m_tags = std::move(tags);
395 }

References data(), and p_impl.

Referenced by ModelView::JsonItemConverter::JsonItemConverterImpl::populate_item().

Here is the call graph for this function:

◆ setDisplayName()

SessionItem * SessionItem::setDisplayName ( const std::string &  name)
virtual

Sets display name (fluent interface).

Reimplemented in ModelView::PropertyItem.

Definition at line 101 of file sessionitem.cpp.

102 {
104  return this;
105 }
QString const & name(EShape k)
Definition: particles.cpp:21

References ModelView::ItemDataRole::DISPLAY, RealSpace::Particles::name(), and setData().

Referenced by ModelView::ColorMapItem::ColorMapItem(), ModelView::GraphItem::GraphItem(), ModelView::ViewportAxisItem::ViewportAxisItem(), ModelView::PropertyItem::setDisplayName(), and TEST_F().

Here is the call graph for this function:

◆ setEditable()

SessionItem * SessionItem::setEditable ( bool  value)

Sets editable flag to given value (fluent interface).

Definition at line 274 of file sessionitem.cpp.

275 {
277  return this;
278 }
void setAppearanceFlag(int flag, bool value)

References ModelView::EDITABLE, and setAppearanceFlag().

Referenced by ModelView::LinkedItem::LinkedItem(), ModelView::PointwiseAxisItem::PointwiseAxisItem(), ModelView::VectorItem::VectorItem(), and TEST_F().

Here is the call graph for this function:

◆ setEditorType()

SessionItem * SessionItem::setEditorType ( const std::string &  editor_type)

Sets editor type (fluent interface).

Allows creating custom editors in the cells of Qt trees and tables.

Definition at line 323 of file sessionitem.cpp.

324 {
325  setData(editor_type, ItemDataRole::EDITORTYPE);
326  return this;
327 }

References ModelView::ItemDataRole::EDITORTYPE, and setData().

Referenced by TEST_F().

Here is the call graph for this function:

◆ setEnabled()

SessionItem * SessionItem::setEnabled ( bool  value)

Sets enabled flag to given value (fluent interface).

Definition at line 290 of file sessionitem.cpp.

291 {
293  return this;
294 }

References ModelView::ENABLED, and setAppearanceFlag().

Referenced by TEST_F().

Here is the call graph for this function:

◆ setModel()

void SessionItem::setModel ( SessionModel model)
private

Definition at line 353 of file sessionitem.cpp.

354 {
355  if (p_impl->m_model)
356  p_impl->m_model->unregisterFromPool(this);
357 
358  p_impl->m_model = model;
359 
360  if (p_impl->m_model)
361  p_impl->m_model->registerInPool(this);
362 
363  for (auto child : children())
364  child->setModel(model);
365 }

References children(), model(), and p_impl.

Here is the call graph for this function:

◆ setParent()

void SessionItem::setParent ( SessionItem parent)
private

Definition at line 348 of file sessionitem.cpp.

349 {
350  p_impl->m_parent = parent;
351 }
SessionItem * parent() const
Returns parent item. Will return nullptr if item doesn't have a parent.

References p_impl, and parent().

Here is the call graph for this function:

◆ setProperty() [1/2]

void SessionItem::setProperty ( const std::string &  tag,
const char *  value 
)
inline

Sets value to property item (specialized for special "const char *" case).

Property is single item registered under certain tag via CompoundItem::addProperty method, the value will be assigned to it's data role.

Definition at line 199 of file sessionitem.h.

200 {
201  setProperty(tag, std::string(value));
202 }
void setProperty(const std::string &tag, const T &value)
Sets value to property item.
Definition: sessionitem.h:190

References setProperty().

Here is the call graph for this function:

◆ setProperty() [2/2]

◆ setToolTip()

SessionItem * SessionItem::setToolTip ( const std::string &  tooltip)

Sets item tooltip (fluent interface).

Definition at line 306 of file sessionitem.cpp.

307 {
308  setData(tooltip, ItemDataRole::TOOLTIP);
309  return this;
310 }
const int TOOLTIP
tooltip for item's data
Definition: mvvm_types.h:34

References setData(), and ModelView::ItemDataRole::TOOLTIP.

Referenced by TEST_F().

Here is the call graph for this function:

◆ tagRow()

TagRow SessionItem::tagRow ( ) const

Returns TagRow of this item under which it is accessible through its parent.

Definition at line 124 of file sessionitem.cpp.

125 {
126  return parent() ? parent()->tagRowOfItem(this) : TagRow();
127 }
Aggregate to hold (tag, row) information for SessionModel.
Definition: tagrow.h:25

References parent(), and tagRowOfItem().

Referenced by ModelView::MoveItemCommand::MoveItemCommand(), gui2::MaterialModel::cloneMaterial(), ModelView::Utils::DeleteItemFromModel(), ModelView::Utils::FindNextSibling(), gui2::ExperimentalDataModel::mergeCanvases(), ModelView::Utils::MoveDown(), ModelView::Utils::MoveUp(), gui2::ExperimentalDataModel::removeCanvas(), gui2::ExperimentalDataModel::removeGraph(), and TEST_F().

Here is the call graph for this function:

◆ tagRowOfItem()

TagRow SessionItem::tagRowOfItem ( const SessionItem item) const

Returns pair of tag and row corresponding to given item.

Returns {"", -1} if given item doesn't belong to children.

Definition at line 188 of file sessionitem.cpp.

189 {
190  return p_impl->m_tags->tagRowOfItem(item);
191 }

References item(), and p_impl.

Referenced by ModelView::Utils::FindPreviousSibling(), insertItem(), ModelView::ItemMapper::ItemMapperImpl::processDataChange(), ModelView::Utils::SinglePropertyItems(), tagRow(), TEST_F(), and ModelView::Utils::TopLevelItems().

Here is the call graph for this function:

◆ takeItem()

SessionItem * SessionItem::takeItem ( const TagRow tagrow)

Removes item from given row from given tag, returns it to the caller.

Definition at line 246 of file sessionitem.cpp.

247 {
248  if (!p_impl->m_tags->canTakeItem(tagrow))
249  return nullptr;
250 
251  if (p_impl->m_model)
252  p_impl->m_model->mapper()->callOnItemAboutToBeRemoved(this, tagrow);
253 
254  auto result = p_impl->m_tags->takeItem(tagrow);
255  result->setParent(nullptr);
256  result->setModel(nullptr);
257  // FIXME remaining problem is that ItemMapper still looking to the model
258  if (p_impl->m_model)
259  p_impl->m_model->mapper()->callOnItemRemoved(this, tagrow);
260 
261  return result;
262 }

References p_impl.

Referenced by ModelView::Data2DItem::insert_axis(), and TEST_F().

◆ toolTip()

std::string SessionItem::toolTip ( ) const

Returns item tooltip, if exists.

Definition at line 298 of file sessionitem.cpp.

299 {
300  return hasData(ItemDataRole::TOOLTIP) ? data<std::string>(ItemDataRole::TOOLTIP)
301  : std::string();
302 }

References hasData(), and ModelView::ItemDataRole::TOOLTIP.

Referenced by TEST_F(), and ModelView::Utils::ToolTipRole().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ JsonItemConverter

friend class JsonItemConverter
friend

Definition at line 122 of file sessionitem.h.

◆ SessionModel

friend class SessionModel
friend

Definition at line 121 of file sessionitem.h.

Member Data Documentation

◆ p_impl


The documentation for this class was generated from the following files: