BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SessionItem Class Reference

Description

Base class for a GUI data item.

SessionItem and SessionModel implement the base structures to store data in the GUI layer.

SessionItem provides

  • Keeping of the project data itself
  • Storing of elements for UI representation, e.g. the label text and the tooltip
  • Generic serialization to XML
  • Hierarchical tree management
  • Method to signal value changes
  • Generic way to change values via QVariant

For realizing the highly generic approach, access to properties, children, values, signals is done by strings. Converting values is done by means provided by QVariant.

A data structure is realized at runtime, not at compile time (therefore e.g. properties are not just data members, but children of type SessionItem). The tree structure, properties, UI etc. are usually created by initialization routines.

By this, the data holding is completely generic and also completely volatile - it can be changed at any time, properties or children can be added or removed to represent different behavior, or even different objects. This realizes kind of a dynamic polymorphy, which can be examined by strings. E.g. to find out whether a child is a property with a value, or a grouping element with more children, the child's modelType() has to be checked against "Property", "GroupProperty", and so on. The model type therefore is comparable to the "class" of the SessionItem.

The hierarchy of a SessionItem and its children is used for

  • representation on the UI (trees)
  • creating the XML hierarchy
  • accessing

Example for creating properties (properties are a replacement for data members):

{
addProperty("Radius", 8.0);
addProperty("Height", 16.0);
}
SessionItem * addProperty(const QString &name, const QVariant &variant)
Add new property item and register new tag. name is the tag name and the display name....

In this example, the text "Radius" will be used

  • on the UI to represent the value (label),
  • for storing the value to the project file (XML tag)
  • for accessing the property (e.g. read/write the value).
  • for identifying the item when signaling a value change

The object has nothing like a

double m_radius;

Relation to core elements

The GUI component does not use core component elements to store data.

As an example, here the representation of simulation options in the core layer:

class SimulationOptions {
public:
// access methods omitted for simplicity
private:
bool m_mc_integration;
bool m_include_specular;
bool m_use_avg_materials;
size_t m_mc_points;
ThreadInfo m_thread_info;
};

And following the corresponding object in the UI layer.

class BA_CORE_API_ SimulationOptionsItem : public SessionItem {
private:
// Strings for accessing the properties
static constexpr auto P_RUN_POLICY{"..."};
static constexpr auto P_NTHREADS{"..."};
static constexpr auto P_COMPUTATION_METHOD{"..."};
static constexpr auto P_MC_POINTS{"..."};
static constexpr auto P_FRESNEL_MATERIAL_METHOD{"..."};
static constexpr auto P_INCLUDE_SPECULAR_PEAK{"..."};
public:
// access methods omitted for simplicity
private:
// no members at all!
};
Base class for a GUI data item.
Definition: SessionItem.h:204
The SimulationOptionsItem class holds simulation status (run policy, number of threads,...

As one can see, no structure is visible at all in the class definition itself. The structure is created in the constructor:

{
ComboProperty policy;
policy << getRunPolicyNames();
policy.setToolTips(getRunPolicyTooltips());
addProperty(P_RUN_POLICY, policy.variant())->setToolTip(tooltip_runpolicy);
ComboProperty nthreads;
nthreads << getCPUUsageOptions();
addProperty(P_NTHREADS, nthreads.variant())->setToolTip(tooltip_nthreads);
ComboProperty computationMethod;
computationMethod << "Analytical"
<< "Monte-Carlo Integration";
addProperty(P_COMPUTATION_METHOD,
computationMethod.variant())->setToolTip(tooltip_computation);
// [Code omitted for simplicity]
mapper()->setOnPropertyChange([this](const QString& name) {
if (name == P_COMPUTATION_METHOD && isTag(P_MC_POINTS)) {
ComboProperty combo = getItemValue(P_COMPUTATION_METHOD).value<ComboProperty>();
if (combo.getValue() == "Analytical") {
getItem(P_MC_POINTS)->setEnabled(false);
} else {
getItem(P_MC_POINTS)->setEnabled(true);
}
} else if (name == P_NTHREADS) {
updateComboItem(P_NTHREADS, getCPUUsageOptions());
} else if (name == P_RUN_POLICY) {
updateComboItem(P_RUN_POLICY, getRunPolicyNames());
}
});
}
Custom property to define list of string values with multiple selections. Intended for QVariant.
Definition: ComboProperty.h:25
QVariant variant() const
Constructs variant enclosing given ComboProperty.
QString getValue() const
void setToolTips(const QStringList &tooltips)
QString const & name(EShape k)
Definition: particles.cpp:20

The onPropertyChange part in the above example shows also the string based access to values as well as types:

mapper()->setOnPropertyChange([this](const QString& name) {
if (name == P_COMPUTATION_METHOD && isTag(P_MC_POINTS))
// ...
getItem(P_MC_POINTS)->setEnabled(true);
else if (name == P_NTHREADS)
updateComboItem(P_NTHREADS, getCPUUsageOptions());
else if (name == P_RUN_POLICY)
updateComboItem(P_RUN_POLICY, getRunPolicyNames());
});
void setOnPropertyChange(std::function< void(QString)> f, const void *caller=nullptr)
Definition: ModelMapper.cpp:39
bool isTag(const QString &name) const
Returns true if tag is available.
ModelMapper * mapper()
Returns the current model mapper of this item. Creates new one if necessary.
void setEnabled(bool enabled)
Flags accessors.
SessionItem * getItem(const QString &tag="", int row=0) const
Returns item in given row of given tag.

Since UI and core are using completely unrelated objects, a conversion between the two components is necessary. This is done with the functions in namespace TransformFromCore and TransformToCore.

For IParticle this looks like this:

std::unique_ptr<IParticle> GUI::Transform::ToCore::createIParticle(const SessionItem&
{
std::unique_ptr<IParticle> P_particle;
if (item.modelType() == "Particle") {
auto& particle_item = static_cast<const ParticleItem&>(item);
P_particle = particle_item.createParticle();
} else if (item.modelType() == "ParticleCoreShell") {
auto& particle_coreshell_item = static_cast<const ParticleCoreShellItem&>(item);
P_particle = particle_coreshell_item.createParticleCoreShell();
} else if (item.modelType() == "ParticleComposition") {
auto& particle_composition_item = static_cast<const ParticleCompositionItem&>(item);
P_particle = particle_composition_item.createParticleComposition();
} else if (item.modelType() == "MesoCrystal") {
auto& mesocrystal_item = static_cast<const MesoCrystalItem&>(item);
P_particle = mesocrystal_item.createMesoCrystal();
}
return P_particle;
}
std::unique_ptr< MesoCrystal > createMesoCrystal() const
std::unique_ptr< ParticleComposition > createParticleComposition() const
std::unique_ptr< ParticleCoreShell > createParticleCoreShell() const
std::unique_ptr< Particle > createParticle() const
T * item(const QString &tag) const
Definition: SessionItem.h:353

This code part again shows the (highly error-prone) string-based type checking.

Definition at line 204 of file SessionItem.h.

Inheritance diagram for SessionItem:
[legend]
Collaboration diagram for SessionItem:
[legend]

Public Member Functions

 SessionItem (const QString &modelType)
 Constructs new item with given model type. The type must be defined. More...
 
virtual ~SessionItem ()
 Destructor deletes all its children and request parent to delete this item. More...
 
QVector< QString > acceptableDefaultItemTypes () const
 Returns vector of acceptable default tag types. More...
 
bool acceptsAsDefaultItem (const QString &item_name) const
 Returns true if model type can be added to default tag. More...
 
SessionItemaddGroupProperty (const QString &groupTag, const GroupInfo &groupInfo)
 
template<typename T >
T * addProperty (const QString &name)
 
SessionItemaddProperty (const QString &name, const QVariant &variant)
 Add new property item and register new tag. name is the tag name and the display name. The property's value will be set to variant. More...
 
virtual bool allowWritingChildToXml (SessionItem *child) const
 
SessionItemchildAt (int row) const
 Returns the child at the given row. More...
 
QVector< SessionItem * > children () const
 Returns vector of all children. More...
 
template<typename T >
QVector< T * > childrenOfType () const
 
QVector< SessionItem * > childrenOfType (const QString &model_type) const
 Returns a vector of all children of the given type. More...
 
int decimals () const
 
QString defaultTag () const
 Get default tag. More...
 
virtual void deserializeBinaryData (const QByteArray &data)
 
QString displayName () const
 Get display name of item, append index if ambigue. More...
 
void emitDataChanged (int role=Qt::DisplayRole)
 Notify model about data changes. More...
 
template<typename T >
T * firstChildOfType () const
 
SessionItemgetChildOfType (const QString &type) const
 Returns the first child of the given type. More...
 
SessionItemgetGroupItem (const QString &groupName) const
 Access subitem of group item. More...
 
SessionItemgetItem (const QString &tag="", int row=0) const
 Returns item in given row of given tag. More...
 
QVector< SessionItem * > getItems (const QString &tag="") const
 Returns vector of all items of given tag. More...
 
QVariant getItemValue (const QString &tag) const
 Directly access value of item under given tag. More...
 
QVector< int > getRoles () const
 Returns vector of all present roles. More...
 
template<typename T >
T & groupItem (const QString &groupName) const
 
bool hasChildren () const
 Indicates whether this SessionItem has any child items. More...
 
template<typename T >
bool hasModelType () const
 
QModelIndex index () const
 Returns model index of this item. More...
 
void insertChild (int row, SessionItem *item, const QString &tag="")
 Insert item into given tag into given row. More...
 
bool isEditable () const
 
bool isEnabled () const
 
bool isTag (const QString &name) const
 Returns true if tag is available. More...
 
template<typename T >
T * item (const QString &tag) const
 
QString itemName () const
 Get item name, return display name if no name is set. More...
 
template<typename T >
QVector< T * > items (const QString &tag="") const
 
RealLimits limits () const
 
ModelMappermapper ()
 Returns the current model mapper of this item. Creates new one if necessary. More...
 
SessionModelmodel () const
 Returns model of this item. More...
 
QString modelType () const
 Get model type. More...
 
int numberOfChildren () const
 Returns total number of children. More...
 
SessionItemparentItem () const
 Returns parent of this item. More...
 
int parentRow ()
 Returns the index of the given item within its parent. Returns -1 when no parent is set. More...
 
virtual void readNonSessionItems (QXmlStreamReader *reader)
 
bool registerTag (const QString &name, int min=0, int max=-1, QStringList modelTypes={})
 Add new tag to this item with given name, min, max and types. max = -1 -> unlimited, modelTypes empty -> all types allowed. More...
 
QVariant roleProperty (int role) const
 Returns corresponding variant under given role, invalid variant when role is not present. More...
 
int rowOfChild (SessionItem *child) const
 Returns row index of given child. More...
 
virtual QByteArray serializeBinaryData () const
 
const SessionItemTagssessionItemTags () const
 
SessionItemsetDecimals (int n)
 
void setDefaultTag (const QString &tag)
 Set default tag. More...
 
void setDisplayName (const QString &display_name)
 Set display name. More...
 
void setEditable (bool enabled)
 
void setEnabled (bool enabled)
 Flags accessors. More...
 
SessionItemsetGroupProperty (const QString &groupTag, const QString &modelType) const
 Set the current type of group item. More...
 
template<typename T >
T * setGroupPropertyType (const QString &groupTag)
 
void setItemName (const QString &name)
 Set item name, add property if necessary. More...
 
void setItemValue (const QString &tag, const QVariant &variant) const
 Directly set value of item under given tag. More...
 
SessionItemsetLimits (const RealLimits &value)
 
bool setRoleProperty (int role, const QVariant &value)
 Set the contained role property to the given value. See also setTranslatorForRolePropertySetter. More...
 
SessionItemsetToolTip (const QString &tooltip)
 
bool setValue (QVariant value)
 Set value, ensure that variant types match. More...
 
QString tagFromItem (const SessionItem *item) const
 Returns the tag name of given item when existing. More...
 
SessionItemtakeItem (int row, const QString &tag)
 Remove item from given row from given tag. More...
 
SessionItemtakeRow (int row)
 Removes row from item and returns the item. More...
 
QString toolTip () const
 
QVariant value () const
 Get value. More...
 
virtual void writeNonSessionItems (QXmlStreamWriter *writer) const
 

Static Public Member Functions

static bool isItemNamePropertyName (const QString &name)
 

Private Member Functions

void changeFlags (bool enabled, int flag)
 internal More...
 
void childDeleted (SessionItem *child)
 
int flags () const
 
int getCopyNumberOfChild (const SessionItem *item) const
 internal More...
 
void setModel (SessionModel *model)
 
void setParentAndModel (SessionItem *parent, SessionModel *model)
 

Private Attributes

QVector< SessionItem * > m_children
 
std::unique_ptr< ModelMapperm_mapper
 
SessionModelm_model
 
SessionItemm_parent
 
std::unique_ptr< SessionItemDatam_properties
 
std::unique_ptr< SessionItemTagsm_tags
 

Static Private Attributes

static constexpr auto P_NAME {"Name"}
 

Friends

class SessionModel
 

Constructor & Destructor Documentation

◆ SessionItem()

SessionItem::SessionItem ( const QString &  modelType)
explicit

Constructs new item with given model type. The type must be defined.

Definition at line 25 of file SessionItem.cpp.

26  : m_parent(nullptr)
27  , m_model(nullptr)
29  , m_tags(new SessionItemTags)
30 {
31  ASSERT(!modelType.isEmpty());
32 
35  setDecimals(3);
36  setLimits(RealLimits::nonnegative());
37 }
Handles all data roles for SessionItem.
Holds all tag info for SessionItem.
SessionItem & setDecimals(int n)
std::unique_ptr< SessionItemData > m_properties
Definition: SessionItem.h:333
void setDisplayName(const QString &display_name)
Set display name.
SessionModel * m_model
Definition: SessionItem.h:331
std::unique_ptr< SessionItemTags > m_tags
Definition: SessionItem.h:334
QString modelType() const
Get model type.
SessionItem * m_parent
Definition: SessionItem.h:330
bool setRoleProperty(int role, const QVariant &value)
Set the contained role property to the given value. See also setTranslatorForRolePropertySetter.
SessionItem & setLimits(const RealLimits &value)

References modelType(), SessionFlags::ModelTypeRole, setDecimals(), setDisplayName(), setLimits(), and setRoleProperty().

Here is the call graph for this function:

◆ ~SessionItem()

SessionItem::~SessionItem ( )
virtual

Destructor deletes all its children and request parent to delete this item.

Definition at line 41 of file SessionItem.cpp.

42 {
43  if (m_mapper)
44  m_mapper->callOnItemDestroy();
45 
46  QVector<SessionItem*>::const_iterator it;
47  for (it = m_children.constBegin(); it != m_children.constEnd(); ++it) {
48  SessionItem* child = *it;
49  if (child)
50  child->setModel(nullptr);
51  delete child;
52  }
53  m_children.clear();
54  if (m_parent && m_model)
55  m_parent->childDeleted(this);
56 }
QVector< SessionItem * > m_children
Definition: SessionItem.h:332
std::unique_ptr< ModelMapper > m_mapper
Definition: SessionItem.h:335
void setModel(SessionModel *model)
void childDeleted(SessionItem *child)

References childDeleted(), m_children, m_mapper, m_model, m_parent, and setModel().

Here is the call graph for this function:

Member Function Documentation

◆ acceptableDefaultItemTypes()

QVector< QString > SessionItem::acceptableDefaultItemTypes ( ) const

Returns vector of acceptable default tag types.

Definition at line 193 of file SessionItem.cpp.

194 {
195  return m_tags->modelTypesForTag(defaultTag()).toVector();
196 }
QString defaultTag() const
Get default tag.

References defaultTag(), and m_tags.

Here is the call graph for this function:

◆ acceptsAsDefaultItem()

bool SessionItem::acceptsAsDefaultItem ( const QString &  item_name) const

Returns true if model type can be added to default tag.

Definition at line 186 of file SessionItem.cpp.

187 {
188  return m_tags->isValid(defaultTag(), item_name);
189 }

References defaultTag(), and m_tags.

Here is the call graph for this function:

◆ addGroupProperty()

SessionItem * SessionItem::addGroupProperty ( const QString &  groupTag,
const GroupInfo groupInfo 
)

Definition at line 306 of file SessionItem.cpp.

307 {
310  ASSERT(groupItem);
311  groupItem->setGroupInfo(groupInfo);
312  registerTag(groupTag, 1, 1, {GroupItem::M_TYPE});
313  groupItem->setDisplayName(groupTag);
314  insertChild(0, groupItem, groupTag);
315  return groupItem;
316 }
static constexpr auto M_TYPE
Definition: GroupItem.h:30
T & groupItem(const QString &groupName) const
Definition: SessionItem.h:413
bool registerTag(const QString &name, int min=0, int max=-1, QStringList modelTypes={})
Add new tag to this item with given name, min, max and types. max = -1 -> unlimited,...
void insertChild(int row, SessionItem *item, const QString &tag="")
Insert item into given tag into given row.
SessionItem * CreateItem(const QString &model_name, SessionItem *parent=nullptr)
create SessionItem of specific type and parent
Definition: ItemFactory.cpp:19

References GUI::Model::ItemFactory::CreateItem(), groupItem(), insertChild(), GroupItem::M_TYPE, and registerTag().

Referenced by MinimizerContainerItem::MinimizerContainerItem().

Here is the call graph for this function:

◆ addProperty() [1/2]

template<typename T >
T * SessionItem::addProperty ( const QString &  name)

Definition at line 394 of file SessionItem.h.

395 {
396  auto property = new T;
397  property->setDisplayName(tagname);
398  registerTag(tagname, 1, 1, QStringList() << property->modelType());
399  insertChild(0, property, tagname);
400  return property;
401 }

References insertChild(), registerTag(), and setDisplayName().

Here is the call graph for this function:

◆ addProperty() [2/2]

SessionItem * SessionItem::addProperty ( const QString &  name,
const QVariant &  variant 
)

Add new property item and register new tag. name is the tag name and the display name. The property's value will be set to variant.

Definition at line 278 of file SessionItem.cpp.

279 {
280  ASSERT(!isTag(name));
281 
283  property->setDisplayName(name);
285  insertChild(0, property, name);
286  property->setValue(variant);
287  return property;
288 }
static constexpr auto M_TYPE
Definition: PropertyItem.h:22

References GUI::Model::ItemFactory::CreateItem(), insertChild(), isTag(), PropertyItem::M_TYPE, GUI::RealSpace::Particles::name(), and registerTag().

Referenced by AmplitudeAxisItem::AmplitudeAxisItem(), BasicAxisItem::BasicAxisItem(), Data1DProperties::Data1DProperties(), Data1DViewItem::Data1DViewItem(), DataItem::DataItem(), DataProperties::DataProperties(), EllipseItem::EllipseItem(), FitParameterItem::FitParameterItem(), FitParameterLinkItem::FitParameterLinkItem(), FitSuiteItem::FitSuiteItem(), GeneticMinimizerItem::GeneticMinimizerItem(), GSLLMAMinimizerItem::GSLLMAMinimizerItem(), GSLMultiMinimizerItem::GSLMultiMinimizerItem(), HorizontalLineItem::HorizontalLineItem(), IntensityDataItem::IntensityDataItem(), JobItem::JobItem(), MaskItem::MaskItem(), MinimizerContainerItem::MinimizerContainerItem(), MinuitMinimizerItem::MinuitMinimizerItem(), PointwiseAxisItem::PointwiseAxisItem(), PolygonItem::PolygonItem(), PolygonPointItem::PolygonPointItem(), RealDataItem::RealDataItem(), RectangleItem::RectangleItem(), SimAnMinimizerItem::SimAnMinimizerItem(), SpecularDataItem::SpecularDataItem(), VerticalLineItem::VerticalLineItem(), and setItemName().

Here is the call graph for this function:

◆ allowWritingChildToXml()

bool SessionItem::allowWritingChildToXml ( SessionItem child) const
virtual

Definition at line 528 of file SessionItem.cpp.

529 {
530  return true;
531 }

Referenced by GUI::Session::XML::writeItemAndChildItems().

◆ changeFlags()

void SessionItem::changeFlags ( bool  enabled,
int  flag 
)
private

internal

Definition at line 568 of file SessionItem.cpp.

569 {
570  int flags = this->flags();
571  if (enabled)
572  flags |= flag;
573  else
574  flags &= ~flag;
575 
577 }
int flags() const

References SessionFlags::FlagRole, flags(), and setRoleProperty().

Referenced by setEditable(), and setEnabled().

Here is the call graph for this function:

◆ childAt()

SessionItem * SessionItem::childAt ( int  row) const

Returns the child at the given row.

Definition at line 102 of file SessionItem.cpp.

103 {
104  return m_children.value(row, nullptr);
105 }

References m_children.

Referenced by SessionModel::index(), and takeRow().

◆ childDeleted()

void SessionItem::childDeleted ( SessionItem child)
private

Definition at line 533 of file SessionItem.cpp.

534 {
535  int index = rowOfChild(child);
536  ASSERT(index != -1);
537  m_children.replace(index, nullptr);
538 }
int rowOfChild(SessionItem *child) const
Returns row index of given child.
QModelIndex index() const
Returns model index of this item.
Definition: SessionItem.cpp:74

References index(), m_children, and rowOfChild().

Referenced by ~SessionItem().

Here is the call graph for this function:

◆ children()

QVector< SessionItem * > SessionItem::children ( ) const

Returns vector of all children.

Definition at line 95 of file SessionItem.cpp.

96 {
97  return m_children;
98 }

References m_children.

Referenced by MaskContainerItem::maskItems(), DataPropertyContainer::propertyItem(), and GUI::Session::XML::writeItemAndChildItems().

◆ childrenOfType() [1/2]

template<typename T >
QVector< T * > SessionItem::childrenOfType

Definition at line 372 of file SessionItem.h.

373 {
374  QVector<T*> result;
375  for (auto* child : m_children)
376  if (child->modelType() == T::M_TYPE)
377  result.append(dynamic_cast<T*>(child));
378 
379  return result;
380 }

References m_children.

◆ childrenOfType() [2/2]

QVector< SessionItem * > SessionItem::childrenOfType ( const QString &  model_type) const

Returns a vector of all children of the given type.

Definition at line 127 of file SessionItem.cpp.

128 {
129  QVector<SessionItem*> result;
130  for (auto* child : m_children)
131  if (child->modelType() == model_type)
132  result.append(child);
133 
134  return result;
135 }

References m_children.

Referenced by ProjectionsPlot::projectionItems(), and SaveProjectionsAssistant::projectionItems().

◆ decimals()

int SessionItem::decimals ( ) const

Definition at line 484 of file SessionItem.cpp.

485 {
486  return roleProperty(SessionFlags::DecimalRole).toInt();
487 }
QVariant roleProperty(int role) const
Returns corresponding variant under given role, invalid variant when role is not present.

References SessionFlags::DecimalRole, and roleProperty().

Referenced by GUI::View::PropertyEditorFactory::CreateEditor().

Here is the call graph for this function:

◆ defaultTag()

QString SessionItem::defaultTag ( ) const

Get default tag.

Definition at line 390 of file SessionItem.cpp.

391 {
392  return roleProperty(SessionFlags::DefaultTagRole).toString();
393 }

References SessionFlags::DefaultTagRole, and roleProperty().

Referenced by acceptableDefaultItemTypes(), acceptsAsDefaultItem(), SessionModel::copy(), getItem(), getItems(), insertChild(), SessionModel::insertNewItem(), SessionModel::moveItem(), and takeItem().

Here is the call graph for this function:

◆ deserializeBinaryData()

void SessionItem::deserializeBinaryData ( const QByteArray &  data)
virtual

Reimplemented in PointwiseAxisItem, and RealDataItem.

Definition at line 522 of file SessionItem.cpp.

522 {}

Referenced by GUI::Session::XML::readItems().

◆ displayName()

QString SessionItem::displayName ( ) const

Get display name of item, append index if ambigue.

Definition at line 404 of file SessionItem.cpp.

405 {
406  QString result = roleProperty(SessionFlags::DisplayNameRole).toString();
407 
408  if (hasModelType<PropertyItem>() || hasModelType<GroupItem>())
409  return result;
410 
411  if (m_parent) {
412  QString tag = m_parent->tagFromItem(this);
413  // if only one child of this type is allowed, return name without change
415  return result;
416 
417  int index = m_parent->getCopyNumberOfChild(this);
418  if (index >= 0)
419  return result + QString::number(index);
420  }
421  return result;
422 }
bool isSingleItemTag(const QString &tagName) const
const SessionItemTags * sessionItemTags() const
int getCopyNumberOfChild(const SessionItem *item) const
internal
QString tagFromItem(const SessionItem *item) const
Returns the tag name of given item when existing.

References SessionFlags::DisplayNameRole, getCopyNumberOfChild(), index(), SessionItemTags::isSingleItemTag(), m_parent, roleProperty(), sessionItemTags(), and tagFromItem().

Referenced by SelectionDescriptor< T >::SelectionDescriptor(), and itemName().

Here is the call graph for this function:

◆ emitDataChanged()

void SessionItem::emitDataChanged ( int  role = Qt::DisplayRole)

Notify model about data changes.

Definition at line 358 of file SessionItem.cpp.

359 {
360  if (m_model) {
361  QModelIndex index = m_model->indexOfItem(this);
362  m_model->dataChanged(index, index.sibling(index.row(), 1), QVector<int>() << role);
363  }
364 }
QModelIndex indexOfItem(SessionItem *item) const

References index(), SessionModel::indexOfItem(), and m_model.

Referenced by GroupItem::onValueChange(), IntensityDataItem::setDatafield(), SpecularDataItem::setDatafield(), setRoleProperty(), and PointwiseAxisItem::updateIndicators().

Here is the call graph for this function:

◆ firstChildOfType()

template<typename T >
T * SessionItem::firstChildOfType

Definition at line 384 of file SessionItem.h.

385 {
386  for (auto* child : m_children)
387  if (child->modelType() == T::M_TYPE)
388  return dynamic_cast<T*>(child);
389 
390  return nullptr;
391 }

References m_children.

◆ flags()

int SessionItem::flags ( ) const
private

Definition at line 557 of file SessionItem.cpp.

558 {
560 
561  if (!flags.isValid())
563 
564  return flags.toInt();
565 }

References SessionFlags::EDITABLE, SessionFlags::ENABLED, SessionFlags::FlagRole, roleProperty(), and SessionFlags::VISIBLE.

Referenced by changeFlags(), isEditable(), and isEnabled().

Here is the call graph for this function:

◆ getChildOfType()

SessionItem * SessionItem::getChildOfType ( const QString &  type) const

Returns the first child of the given type.

Definition at line 116 of file SessionItem.cpp.

117 {
118  for (auto* child : m_children)
119  if (child->modelType() == type)
120  return child;
121 
122  return nullptr;
123 }

References m_children.

Referenced by GroupItemController::currentItem(), GroupItemController::getItemOfType(), and GroupItemController::setCurrentType().

◆ getCopyNumberOfChild()

int SessionItem::getCopyNumberOfChild ( const SessionItem item) const
private

internal

Definition at line 580 of file SessionItem.cpp.

581 {
582  if (!item)
583  return -1;
584  int result = -1;
585  int count = 0;
586  QString model_type = item->modelType();
587  // check child items:
588  for (auto* p_child_item : m_children) {
589  QString child_type = p_child_item->modelType();
590  if (p_child_item == item)
591  result = count;
592  if (child_type == model_type && !p_child_item->isTag(P_NAME))
593  ++count;
594  }
595  if (count > 1)
596  return result;
597  return -1;
598 }
static constexpr auto P_NAME
Definition: SessionItem.h:208

References item(), m_children, and P_NAME.

Referenced by displayName().

Here is the call graph for this function:

◆ getGroupItem()

SessionItem * SessionItem::getGroupItem ( const QString &  groupName) const

Access subitem of group item.

Definition at line 327 of file SessionItem.cpp.

328 {
329  return item<GroupItem>(groupName)->currentItem();
330 }

Referenced by groupItem(), and setGroupPropertyType().

◆ getItem()

SessionItem * SessionItem::getItem ( const QString &  tag = "",
int  row = 0 
) const

Returns item in given row of given tag.

Definition at line 200 of file SessionItem.cpp.

201 {
202  const QString tagName = tag.isEmpty() ? defaultTag() : tag;
203 
204  if (!m_tags->isValid(tagName))
205  return nullptr;
206 
207  if (m_tags->childCount(tagName) == 0)
208  return nullptr;
209 
210  if (row < 0 || row >= m_tags->childCount(tagName))
211  return nullptr;
212 
213  int index = m_tags->indexFromTagRow(tagName, row);
214  ASSERT(index >= 0);
215  ASSERT(index < m_children.size());
216  return m_children[index];
217 }

References defaultTag(), index(), m_children, and m_tags.

Referenced by FitParameterItem::FitParameterItem(), EllipseItem::angle(), DataItem::axesUnits(), Data1DViewItem::axesUnitsDescriptor(), BasicAxisItem::binsItem(), FitSuiteItem::createFitParametersContainer(), JobItem::createFitSuiteItem(), FitSuiteItem::createMinimizerContainer(), JobItem::dataItem(), RealDataItem::dataItem(), JobItem::dataItemView(), JobItem::fitSuiteItem(), DataItem::getAxesUnitsItem(), getItemValue(), IntensityDataItem::gradient(), RealDataItem::initDataItem(), FitParameterItem::initMinMaxValues(), JobItem::intensityDataItem(), JobItem::isValidForFitting(), item(), FitParameterLinkItem::linkItem(), AmplitudeAxisItem::logScaleItem(), IntensityDataItem::maskContainerItem(), MaskItem::maskValueItem(), BasicAxisItem::max(), FitParameterItem::maximumItem(), BasicAxisItem::maxItem(), BasicAxisItem::min(), FitParameterItem::minimumItem(), BasicAxisItem::minItem(), RealDataItem::nativeData(), MinimizerContainerItem::normFunction(), MinimizerContainerItem::objectiveMetric(), VerticalLineItem::posX(), HorizontalLineItem::posY(), IntensityDataItem::projectionContainerItem(), JobItem::realDataItem(), BasicAxisItem::serialize(), PolygonPointItem::serialize(), AmplitudeAxisItem::serialize(), RectangleItem::serialize(), PolygonItem::serialize(), VerticalLineItem::serialize(), HorizontalLineItem::serialize(), EllipseItem::serialize(), MaskAllItem::serialize(), PointwiseAxisItem::serialize(), setItemValue(), FitParameterItem::setLimitEnabled(), RealDataItem::setNativeDataUnits(), FitParameterItem::startValueItem(), BasicAxisItem::titleItem(), FitParameterItem::typeItem(), MinuitMinimizerItem::valueDescriptorsForUI(), GSLMultiMinimizerItem::valueDescriptorsForUI(), GeneticMinimizerItem::valueDescriptorsForUI(), SimAnMinimizerItem::valueDescriptorsForUI(), GSLLMAMinimizerItem::valueDescriptorsForUI(), BasicAxisItem::visibilityItem(), EllipseItem::xCenter(), RectangleItem::xLow(), EllipseItem::xRadius(), RectangleItem::xUp(), EllipseItem::yCenter(), RectangleItem::yLow(), EllipseItem::yRadius(), and RectangleItem::yUp().

Here is the call graph for this function:

◆ getItems()

QVector< SessionItem * > SessionItem::getItems ( const QString &  tag = "") const

Returns vector of all items of given tag.

Definition at line 221 of file SessionItem.cpp.

222 {
223  const QString tagName = tag.isEmpty() ? defaultTag() : tag;
224  if (!m_tags->isValid(tagName))
225  return QVector<SessionItem*>();
226 
227  int index = m_tags->tagStartIndex(tagName);
228  ASSERT(index >= 0 && index <= m_children.size());
229  return m_children.mid(index, m_tags->childCount(tagName));
230 }

References defaultTag(), index(), m_children, and m_tags.

Referenced by MaskUnitsConverter::convertIntensityDataItem(), SessionModel::copy(), GroupItem::groupItems(), items(), SessionModel::moveItem(), DataPropertyContainer::propertyItem(), DataPropertyContainer::propertyItems(), and takeRow().

Here is the call graph for this function:

◆ getItemValue()

QVariant SessionItem::getItemValue ( const QString &  tag) const

Directly access value of item under given tag.

Definition at line 292 of file SessionItem.cpp.

293 {
294  ASSERT(isTag(tag));
295  return getItem(tag)->value();
296 }
QVariant value() const
Get value.

References getItem(), isTag(), and value().

Referenced by FitParameterItem::attLimits(), Data1DViewItem::axesUnits(), JobItem::beginTime(), BasicAxisItem::binCount(), FitSuiteItem::chi2(), Data1DProperties::color(), Data1DProperties::colorName(), MaskUnitsConverter::convertCoordinate(), MinimizerContainerItem::createMetric(), MinuitMinimizerItem::createMinimizer(), GSLMultiMinimizerItem::createMinimizer(), GeneticMinimizerItem::createMinimizer(), SimAnMinimizerItem::createMinimizer(), GSLLMAMinimizerItem::createMinimizer(), RectangleItem::createShape(), VerticalLineItem::createShape(), HorizontalLineItem::createShape(), EllipseItem::createShape(), DataProperties::dataItem(), JobItem::endTime(), DataItem::fileName(), JobItem::getComments(), IntensityDataItem::getGradient(), JobItem::getIdentifier(), JobItem::getProgress(), JobItem::getStatus(), PointwiseAxisItem::getUnitsLabel(), FitParameterItem::initMinMaxValues(), RealDataItem::instrumentId(), JobItem::instrumentName(), PolygonItem::isClosed(), IntensityDataItem::isInterpolated(), AmplitudeAxisItem::isLocked(), AmplitudeAxisItem::isLogScale(), BasicAxisItem::isTitleVisible(), FitParameterItem::isValid(), MaskItem::isVisibleValue(), itemName(), FitSuiteItem::iterationCount(), Data1DProperties::line(), FitParameterLinkItem::link(), MaskItem::maskValue(), FitParameterItem::maximum(), FitParameterItem::minimum(), RealDataItem::nativeDataUnits(), Data1DProperties::nextColorName(), PropertyRepeater::onPropertyChanged(), FitParameterItem::parameterType(), PolygonPointItem::posX(), PolygonPointItem::posY(), JobItem::presentationType(), Data1DProperties::scatter(), DataItem::selectedCoords(), PropertyRepeater::setOnChildPropertyChange(), FitParameterItem::startValue(), BasicAxisItem::title(), FitParameterLinkItem::title(), and FitSuiteItem::updateInterval().

Here is the call graph for this function:

◆ getRoles()

QVector< int > SessionItem::getRoles ( ) const

Returns vector of all present roles.

Definition at line 351 of file SessionItem.cpp.

352 {
353  return m_properties->roles();
354 }

References m_properties.

Referenced by GUI::Session::XML::writeItemAndChildItems().

◆ groupItem()

template<typename T >
T & SessionItem::groupItem ( const QString &  groupName) const

Definition at line 413 of file SessionItem.h.

414 {
415  auto* t = dynamic_cast<T*>(getGroupItem(groupName));
416  ASSERT(t);
417  return *t;
418 }
SessionItem * getGroupItem(const QString &groupName) const
Access subitem of group item.

References getGroupItem().

Referenced by addGroupProperty().

Here is the call graph for this function:

◆ hasChildren()

bool SessionItem::hasChildren ( ) const

Indicates whether this SessionItem has any child items.

Definition at line 81 of file SessionItem.cpp.

82 {
83  return numberOfChildren() > 0;
84 }
int numberOfChildren() const
Returns total number of children.
Definition: SessionItem.cpp:88

References numberOfChildren().

Referenced by IntensityDataItem::hasProjections().

Here is the call graph for this function:

◆ hasModelType()

template<typename T >
bool SessionItem::hasModelType

Definition at line 421 of file SessionItem.h.

422 {
423  return modelType() == T::M_TYPE;
424 }

References modelType().

Referenced by MaskViewFactory::createMaskView(), FitParameterModel::flags(), FitParameterModel::index(), FitParameterModel::indexOfItem(), FitParameterWidget::onFitParametersSelectionChanged(), FitParameterModel::rowCount(), and MaskGraphicsScene::updateViews().

Here is the call graph for this function:

◆ index()

QModelIndex SessionItem::index ( ) const

Returns model index of this item.

Definition at line 74 of file SessionItem.cpp.

75 {
76  return model() ? model()->indexOfItem(const_cast<SessionItem*>(this)) : QModelIndex();
77 }
SessionModel * model() const
Returns model of this item.
Definition: SessionItem.cpp:60

References SessionModel::indexOfItem(), and model().

Referenced by childDeleted(), MaskContainerItem::clear(), FitParameterContainerItem::createParameters(), displayName(), emitDataChanged(), getItem(), getItems(), insertChild(), FitParameterModel::isValidSourceItem(), ParameterItem::linkToSessionItem(), JobModel::removeJob(), FitParameterContainerItem::setValuesInParameterContainer(), IntensityDataProjectionsWidget::subscribeToItem(), tagFromItem(), and takeItem().

Here is the call graph for this function:

◆ insertChild()

void SessionItem::insertChild ( int  row,
SessionItem item,
const QString &  tag = "" 
)

Insert item into given tag into given row.

Definition at line 233 of file SessionItem.cpp.

234 {
235  ASSERT(item);
236  ASSERT(!item->parentItem());
237 
238  const QString tagName = tag.isEmpty() ? defaultTag() : tag;
239  ASSERT(m_tags->isValid(tagName, item->modelType()));
240 
241  int index = m_tags->insertIndexFromTagRow(tagName, row);
242  ASSERT(index >= 0);
243  ASSERT(index <= m_children.size());
244 
245  if (m_model)
246  m_model->beginInsertRows(this->index(), index, index);
247 
248  item->setParentAndModel(this, m_model);
249  m_children.insert(index, item);
250 
251  m_tags->addChild(tagName);
252  if (m_model)
253  m_model->endInsertRows();
254 }

References defaultTag(), index(), item(), m_children, m_model, and m_tags.

Referenced by GroupItemController::GroupItemController(), JobItem::addDataViewItem(), addGroupProperty(), DataPropertyContainer::addItem(), MaskContainerItem::addMask(), PolygonItem::addPoint(), addProperty(), GUI::Model::ItemFactory::CreateItem(), GroupItemController::getItemOfType(), MaskItems::insertMask(), MaskContainerItem::insertMask(), SessionModel::insertNewItem(), SessionModel::moveItem(), and GroupItemController::setCurrentType().

Here is the call graph for this function:

◆ isEditable()

bool SessionItem::isEditable ( ) const

Definition at line 468 of file SessionItem.cpp.

469 {
470  return flags() & SessionFlags::EDITABLE;
471 }

References SessionFlags::EDITABLE, and flags().

Referenced by SessionModel::flags().

Here is the call graph for this function:

◆ isEnabled()

bool SessionItem::isEnabled ( ) const

Definition at line 463 of file SessionItem.cpp.

464 {
465  return flags() & SessionFlags::ENABLED;
466 }

References SessionFlags::ENABLED, and flags().

Referenced by SessionModel::flags().

Here is the call graph for this function:

◆ isItemNamePropertyName()

bool SessionItem::isItemNamePropertyName ( const QString &  name)
static

Definition at line 446 of file SessionItem.cpp.

447 {
448  return P_NAME == name;
449 }

References GUI::RealSpace::Particles::name(), and P_NAME.

Here is the call graph for this function:

◆ isTag()

bool SessionItem::isTag ( const QString &  name) const

Returns true if tag is available.

Definition at line 166 of file SessionItem.cpp.

167 {
168  return m_tags->isValid(name);
169 }

References m_tags, and GUI::RealSpace::Particles::name().

Referenced by addProperty(), MaskUnitsConverter::convertCoordinate(), getItemValue(), JobItem::isValidForFitting(), itemName(), setItemName(), setItemValue(), and FitParameterItem::setLimitEnabled().

Here is the call graph for this function:

◆ item()

template<typename T >
T * SessionItem::item ( const QString &  tag) const

◆ itemName()

QString SessionItem::itemName ( ) const

Get item name, return display name if no name is set.

Definition at line 432 of file SessionItem.cpp.

433 {
434  return isTag(P_NAME) ? getItemValue(P_NAME).toString() : displayName();
435 }
QString displayName() const
Get display name of item, append index if ambigue.
QVariant getItemValue(const QString &tag) const
Directly access value of item under given tag.

References displayName(), getItemValue(), isTag(), and P_NAME.

Referenced by SessionModel::data(), RealDataItem::dataName(), JobItem::jobName(), MaskItem::maskName(), GUI::Session::XML::readItems(), MaskGraphicsScene::setItemName(), Plot1D::subscribeToItem(), SpecularPlot::subscribeToItem(), ColorMap::subscribeToItem(), ProjectionsPlot::subscribeToItem(), and JobItem::updateIntensityDataFileName().

Here is the call graph for this function:

◆ items()

template<typename T >
QVector< T * > SessionItem::items ( const QString &  tag = "") const

Definition at line 361 of file SessionItem.h.

362 {
363  QVector<T*> result;
364 
365  for (SessionItem* item : getItems(tag))
366  if (auto* titem = dynamic_cast<T*>(item))
367  result.push_back(titem);
368  return result;
369 }
QVector< SessionItem * > getItems(const QString &tag="") const
Returns vector of all items of given tag.

References getItems(), and item().

Referenced by DataPropertyContainer::dataItems(), takeRow(), and SessionModel::topItem().

Here is the call graph for this function:

◆ limits()

RealLimits SessionItem::limits ( ) const

Definition at line 473 of file SessionItem.cpp.

474 {
475  return roleProperty(SessionFlags::LimitsRole).value<RealLimits>();
476 }

References SessionFlags::LimitsRole, and roleProperty().

Referenced by GUI::View::PropertyEditorFactory::CreateEditor(), FitParameterContainerItem::createParameters(), and FitParameterItem::initMinMaxValues().

Here is the call graph for this function:

◆ mapper()

◆ model()

◆ modelType()

◆ numberOfChildren()

int SessionItem::numberOfChildren ( ) const

◆ parentItem()

◆ parentRow()

int SessionItem::parentRow ( )

Returns the index of the given item within its parent. Returns -1 when no parent is set.

Definition at line 148 of file SessionItem.cpp.

149 {
150  if (parentItem())
151  return parentItem()->rowOfChild(this);
152  return -1;
153 }
SessionItem * parentItem() const
Returns parent of this item.
Definition: SessionItem.cpp:67

References parentItem(), and rowOfChild().

Referenced by FitParameterModel::indexOfItem(), and FitParameterModel::parent().

Here is the call graph for this function:

◆ readNonSessionItems()

void SessionItem::readNonSessionItems ( QXmlStreamReader *  reader)
virtual

Reimplemented in JobItem.

Definition at line 526 of file SessionItem.cpp.

526 {}

Referenced by GUI::Session::XML::readItems().

◆ registerTag()

bool SessionItem::registerTag ( const QString &  name,
int  min = 0,
int  max = -1,
QStringList  modelTypes = {} 
)

Add new tag to this item with given name, min, max and types. max = -1 -> unlimited, modelTypes empty -> all types allowed.

Definition at line 159 of file SessionItem.cpp.

160 {
161  return m_tags->registerTag(name, min, max, modelTypes);
162 }

References m_tags, and GUI::RealSpace::Particles::name().

Referenced by Data1DViewItem::Data1DViewItem(), DataPropertyContainer::DataPropertyContainer(), FitParameterContainerItem::FitParameterContainerItem(), FitParameterItem::FitParameterItem(), FitSuiteItem::FitSuiteItem(), GroupItem::GroupItem(), IntensityDataItem::IntensityDataItem(), JobItem::JobItem(), MaskContainerItem::MaskContainerItem(), PolygonItem::PolygonItem(), ProjectionContainerItem::ProjectionContainerItem(), RealDataItem::RealDataItem(), addGroupProperty(), addProperty(), and SessionModel::createRootItem().

Here is the call graph for this function:

◆ roleProperty()

QVariant SessionItem::roleProperty ( int  role) const

Returns corresponding variant under given role, invalid variant when role is not present.

Definition at line 334 of file SessionItem.cpp.

335 {
336  return m_properties->data(role);
337 }

References m_properties.

Referenced by GUI::View::PropertyEditorFactory::CreateEditor(), decimals(), defaultTag(), displayName(), flags(), limits(), modelType(), toolTip(), value(), and GUI::Session::XML::writeItemAndChildItems().

◆ rowOfChild()

int SessionItem::rowOfChild ( SessionItem child) const

Returns row index of given child.

Definition at line 109 of file SessionItem.cpp.

110 {
111  return m_children.indexOf(child);
112 }

Referenced by childDeleted(), SessionModel::indexOfItem(), SessionModel::moveItem(), ProjectionsEditorCanvas::onLeavingColorMap(), and parentRow().

◆ serializeBinaryData()

QByteArray SessionItem::serializeBinaryData ( ) const
virtual

Reimplemented in PointwiseAxisItem, and RealDataItem.

Definition at line 517 of file SessionItem.cpp.

518 {
519  return QByteArray();
520 }

Referenced by GUI::Session::XML::writeItemAndChildItems().

◆ sessionItemTags()

const SessionItemTags * SessionItem::sessionItemTags ( ) const

Definition at line 171 of file SessionItem.cpp.

172 {
173  return m_tags.get();
174 }

References m_tags.

Referenced by displayName(), SessionModel::insertNewItem(), and SessionModel::moveItem().

◆ setDecimals()

SessionItem & SessionItem::setDecimals ( int  n)

Definition at line 489 of file SessionItem.cpp.

490 {
492  return *this;
493 }

References SessionFlags::DecimalRole, and setRoleProperty().

Referenced by BasicAxisItem::BasicAxisItem(), and SessionItem().

Here is the call graph for this function:

◆ setDefaultTag()

void SessionItem::setDefaultTag ( const QString &  tag)

◆ setDisplayName()

void SessionItem::setDisplayName ( const QString &  display_name)

Set display name.

Definition at line 426 of file SessionItem.cpp.

427 {
429 }

References SessionFlags::DisplayNameRole, and setRoleProperty().

Referenced by SessionItem(), addProperty(), FitParameterContainerItem::createFitParameter(), and GUI::Session::XML::readItems().

Here is the call graph for this function:

◆ setEditable()

void SessionItem::setEditable ( bool  enabled)

Definition at line 458 of file SessionItem.cpp.

459 {
461 }
void changeFlags(bool enabled, int flag)
internal

References changeFlags(), and SessionFlags::EDITABLE.

Referenced by JobItem::JobItem(), and FitParameterItem::setLimitEnabled().

Here is the call graph for this function:

◆ setEnabled()

void SessionItem::setEnabled ( bool  enabled)

Flags accessors.

Definition at line 453 of file SessionItem.cpp.

454 {
456 }

References changeFlags(), and SessionFlags::ENABLED.

Referenced by FitParameterItem::FitParameterItem(), MaskAllItem::MaskAllItem(), PointwiseAxisItem::PointwiseAxisItem(), GroupItemController::getItemOfType(), and FitParameterItem::setLimitEnabled().

Here is the call graph for this function:

◆ setGroupProperty()

SessionItem * SessionItem::setGroupProperty ( const QString &  groupTag,
const QString &  modelType 
) const

Set the current type of group item.

Definition at line 320 of file SessionItem.cpp.

321 {
322  return item<GroupItem>(groupTag)->setCurrentType(modelType);
323 }

References modelType().

Referenced by setGroupPropertyType().

Here is the call graph for this function:

◆ setGroupPropertyType()

template<typename T >
T * SessionItem::setGroupPropertyType ( const QString &  groupTag)

Definition at line 404 of file SessionItem.h.

405 {
406  SessionItem* item = getGroupItem(groupTag);
407  if (!item->hasModelType<T>())
408  return dynamic_cast<T*>(setGroupProperty(groupTag, T::M_TYPE));
409  return dynamic_cast<T*>(item);
410 }
SessionItem * setGroupProperty(const QString &groupTag, const QString &modelType) const
Set the current type of group item.

References getGroupItem(), item(), and setGroupProperty().

Here is the call graph for this function:

◆ setItemName()

void SessionItem::setItemName ( const QString &  name)

Set item name, add property if necessary.

Definition at line 438 of file SessionItem.cpp.

439 {
440  if (isTag(P_NAME))
442  else
444 }
void setItemValue(const QString &tag, const QVariant &variant) const
Directly set value of item under given tag.

References addProperty(), isTag(), GUI::RealSpace::Particles::name(), P_NAME, and setItemValue().

Referenced by EllipseItem::EllipseItem(), HorizontalLineItem::HorizontalLineItem(), JobItem::JobItem(), MaskAllItem::MaskAllItem(), PolygonItem::PolygonItem(), PolygonPointItem::PolygonPointItem(), RealDataItem::RealDataItem(), RectangleItem::RectangleItem(), VerticalLineItem::VerticalLineItem(), RealDataItem::setDataName(), MaskGraphicsScene::setItemName(), JobItem::setJobName(), and MaskItem::setMaskName().

Here is the call graph for this function:

◆ setItemValue()

void SessionItem::setItemValue ( const QString &  tag,
const QVariant &  variant 
) const

Directly set value of item under given tag.

Definition at line 300 of file SessionItem.cpp.

301 {
302  ASSERT(isTag(tag));
303  getItem(tag)->setValue(variant);
304 }
bool setValue(QVariant value)
Set value, ensure that variant types match.

References getItem(), isTag(), and setValue().

Referenced by MaskUnitsConverter::convertCoordinate(), PointwiseAxisItem::init(), FitParameterItem::initMinMaxValues(), RealDataItem::linkToInstrument(), EllipseItem::setAngle(), Data1DViewItem::setAxesUnits(), DataItem::setAxesUnits(), JobItem::setBeginTime(), BasicAxisItem::setBinCount(), FitSuiteItem::setChi2(), Data1DProperties::setColorProperty(), JobItem::setComments(), DataProperties::setDataItem(), JobItem::setEndTime(), DataItem::setFileName(), IntensityDataItem::setGradient(), JobItem::setIdentifier(), JobItem::setInstrumentName(), IntensityDataItem::setInterpolated(), PolygonItem::setIsClosed(), MaskItem::setIsVisibleValue(), setItemName(), FitSuiteItem::setIterationCount(), Data1DProperties::setLineProperty(), FitParameterLinkItem::setLink(), AmplitudeAxisItem::setLocked(), AmplitudeAxisItem::setLogScale(), BasicAxisItem::setLowerBound(), MaskItem::setMaskValue(), FitParameterItem::setMaximum(), FitParameterItem::setMinimum(), PolygonPointItem::setPosX(), VerticalLineItem::setPosX(), PolygonPointItem::setPosY(), HorizontalLineItem::setPosY(), JobItem::setPresentationType(), JobItem::setProgress(), Data1DProperties::setScatterProperty(), FitParameterItem::setStartValue(), JobItem::setStatus(), BasicAxisItem::setTitle(), FitParameterLinkItem::setTitle(), FitSuiteItem::setUpdateInterval(), BasicAxisItem::setUpperBound(), BasicAxisItem::setVisibilityValue(), EllipseItem::setXCenter(), RectangleItem::setXLow(), EllipseItem::setXRadius(), RectangleItem::setXUp(), EllipseItem::setYCenter(), RectangleItem::setYLow(), EllipseItem::setYRadius(), RectangleItem::setYUp(), and RealDataItem::unlinkFromInstrument().

Here is the call graph for this function:

◆ setLimits()

SessionItem & SessionItem::setLimits ( const RealLimits &  value)

Definition at line 478 of file SessionItem.cpp.

479 {
480  setRoleProperty(SessionFlags::LimitsRole, QVariant::fromValue<RealLimits>(value));
481  return *this;
482 }

References SessionFlags::LimitsRole, setRoleProperty(), and value().

Referenced by BasicAxisItem::BasicAxisItem(), EllipseItem::EllipseItem(), FitParameterItem::FitParameterItem(), HorizontalLineItem::HorizontalLineItem(), PolygonPointItem::PolygonPointItem(), RectangleItem::RectangleItem(), SessionItem(), VerticalLineItem::VerticalLineItem(), and FitParameterItem::initMinMaxValues().

Here is the call graph for this function:

◆ setModel()

void SessionItem::setModel ( SessionModel model)
private

Definition at line 546 of file SessionItem.cpp.

547 {
548  m_model = model;
549 
550  if (m_mapper)
551  m_mapper->setItem(this);
552 
553  for (auto& child : m_children)
554  child->setModel(model);
555 }

References m_children, m_mapper, m_model, and model().

Referenced by ~SessionItem(), SessionModel::createRootItem(), and setParentAndModel().

Here is the call graph for this function:

◆ setParentAndModel()

void SessionItem::setParentAndModel ( SessionItem parent,
SessionModel model 
)
private

Definition at line 540 of file SessionItem.cpp.

541 {
542  setModel(model);
543  m_parent = parent;
544 }

References m_parent, model(), and setModel().

Referenced by takeItem().

Here is the call graph for this function:

◆ setRoleProperty()

bool SessionItem::setRoleProperty ( int  role,
const QVariant &  value 
)

Set the contained role property to the given value. See also setTranslatorForRolePropertySetter.

Set variant to role, create role if not present yet.

Definition at line 341 of file SessionItem.cpp.

342 {
343  bool result = m_properties->setData(role, value);
344  if (result)
345  emitDataChanged(role);
346  return result;
347 }
void emitDataChanged(int role=Qt::DisplayRole)
Notify model about data changes.

References emitDataChanged(), m_properties, and value().

Referenced by SessionItem(), changeFlags(), GUI::Session::XML::readProperty(), SessionModel::setData(), setDecimals(), setDefaultTag(), setDisplayName(), setLimits(), setToolTip(), and setValue().

Here is the call graph for this function:

◆ setToolTip()

SessionItem & SessionItem::setToolTip ( const QString &  tooltip)

Definition at line 500 of file SessionItem.cpp.

501 {
502  setRoleProperty(Qt::ToolTipRole, tooltip);
503  return *this;
504 }

References setRoleProperty().

Referenced by GeneticMinimizerItem::GeneticMinimizerItem(), GSLLMAMinimizerItem::GSLLMAMinimizerItem(), GSLMultiMinimizerItem::GSLMultiMinimizerItem(), MinimizerContainerItem::MinimizerContainerItem(), MinuitMinimizerItem::MinuitMinimizerItem(), and SimAnMinimizerItem::SimAnMinimizerItem().

Here is the call graph for this function:

◆ setValue()

bool SessionItem::setValue ( QVariant  value)

Set value, ensure that variant types match.

Definition at line 382 of file SessionItem.cpp.

383 {
385  return setRoleProperty(Qt::DisplayRole, value);
386 }
bool CompatibleVariantTypes(const QVariant &oldValue, const QVariant &newValue)
Returns true if variants has compatible types.
Definition: VariantUtil.cpp:25

References GUI::Util::Variant::CompatibleVariantTypes(), setRoleProperty(), and value().

Referenced by DoubleDescriptor::DoubleDescriptor(), SelectionDescriptor< T >::SelectionDescriptor(), UIntDescriptor::UIntDescriptor(), IntensityDataPropertyWidget::createCheckBox(), SpecularDataPropertyWidget::createCheckBox(), IntensityDataPropertyWidget::createTextEdit(), SpecularDataPropertyWidget::createTextEdit(), setItemValue(), RealDataItem::setNativeDataUnits(), and GroupItem::updateComboValue().

Here is the call graph for this function:

◆ tagFromItem()

QString SessionItem::tagFromItem ( const SessionItem item) const

Returns the tag name of given item when existing.

Definition at line 178 of file SessionItem.cpp.

179 {
180  int index = m_children.indexOf(const_cast<SessionItem*>(item));
181  return m_tags->tagFromIndex(index);
182 }

References index(), item(), m_children, and m_tags.

Referenced by displayName(), ModelMapper::onDataChanged(), PropertyRepeater::setOnChildPropertyChange(), takeRow(), and GUI::Session::XML::writeItemAndChildItems().

Here is the call graph for this function:

◆ takeItem()

SessionItem * SessionItem::takeItem ( int  row,
const QString &  tag 
)

Remove item from given row from given tag.

Definition at line 258 of file SessionItem.cpp.

259 {
260  const QString tagName = tag.isEmpty() ? defaultTag() : tag;
261  ASSERT(m_tags->isValid(tagName));
262  ASSERT(!m_tags->isSingleItemTag(tagName));
263 
264  int index = m_tags->indexFromTagRow(tagName, row);
265  ASSERT(index >= 0 && index <= m_children.size());
266 
267  if (m_model)
268  m_model->beginRemoveRows(this->index(), index, index);
269  SessionItem* result = m_children.takeAt(index);
270  result->setParentAndModel(nullptr, nullptr);
271 
272  m_tags->removeChild(tagName);
273  if (m_model)
274  m_model->endRemoveRows();
275  return result;
276 }
void setParentAndModel(SessionItem *parent, SessionModel *model)

References defaultTag(), index(), m_children, m_model, m_tags, and setParentAndModel().

Referenced by SessionModel::moveItem(), and takeRow().

Here is the call graph for this function:

◆ takeRow()

SessionItem * SessionItem::takeRow ( int  row)

Removes row from item and returns the item.

Definition at line 139 of file SessionItem.cpp.

140 {
141  SessionItem* item = childAt(row);
142  QString tag = tagFromItem(item);
143  auto items = getItems(tag);
144  return takeItem(items.indexOf(item), tag);
145 }
SessionItem * takeItem(int row, const QString &tag)
Remove item from given row from given tag.
QVector< T * > items(const QString &tag="") const
Definition: SessionItem.h:361
SessionItem * childAt(int row) const
Returns the child at the given row.

References childAt(), getItems(), item(), items(), tagFromItem(), and takeItem().

Referenced by FitComparison1DViewController::deleteDiffViewItem(), SessionModel::moveItem(), ProjectionsEditorCanvas::onLeavingColorMap(), and SessionModel::removeRows().

Here is the call graph for this function:

◆ toolTip()

QString SessionItem::toolTip ( ) const

Definition at line 495 of file SessionItem.cpp.

496 {
497  return roleProperty(Qt::ToolTipRole).toString();
498 }

References roleProperty().

Referenced by SelectionDescriptor< T >::SelectionDescriptor().

Here is the call graph for this function:

◆ value()

◆ writeNonSessionItems()

void SessionItem::writeNonSessionItems ( QXmlStreamWriter *  writer) const
virtual

Reimplemented in JobItem.

Definition at line 524 of file SessionItem.cpp.

524 {}

Referenced by GUI::Session::XML::writeItemAndChildItems().

Friends And Related Function Documentation

◆ SessionModel

friend class SessionModel
friend

Definition at line 205 of file SessionItem.h.

Member Data Documentation

◆ m_children

◆ m_mapper

std::unique_ptr<ModelMapper> SessionItem::m_mapper
private

Definition at line 335 of file SessionItem.h.

Referenced by ~SessionItem(), mapper(), and setModel().

◆ m_model

SessionModel* SessionItem::m_model
private

Definition at line 331 of file SessionItem.h.

Referenced by ~SessionItem(), emitDataChanged(), insertChild(), model(), setModel(), and takeItem().

◆ m_parent

SessionItem* SessionItem::m_parent
private

Definition at line 330 of file SessionItem.h.

Referenced by ~SessionItem(), displayName(), parentItem(), and setParentAndModel().

◆ m_properties

std::unique_ptr<SessionItemData> SessionItem::m_properties
private

Definition at line 333 of file SessionItem.h.

Referenced by getRoles(), roleProperty(), and setRoleProperty().

◆ m_tags

◆ P_NAME

constexpr auto SessionItem::P_NAME {"Name"}
staticconstexprprivate

Definition at line 208 of file SessionItem.h.

Referenced by getCopyNumberOfChild(), isItemNamePropertyName(), itemName(), and setItemName().


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