BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
compounditem.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/model/compounditem.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include "mvvm/model/itemutils.h"
17 
18 using namespace ModelView;
19 
20 namespace {
21 bool has_custom_display_name(const SessionItem* item)
22 {
23  return item->SessionItem::displayName() != item->modelType();
24 }
25 } // namespace
26 
27 CompoundItem::CompoundItem(const std::string& modelType) : SessionItem(modelType) {}
28 
29 std::string CompoundItem::displayName() const
30 {
31  if (has_custom_display_name(this))
32  return SessionItem::displayName();
33 
34  int copy_number = Utils::CopyNumber(this);
35  return copy_number != -1 ? SessionItem::displayName() + std::to_string(copy_number)
37 }
std::string displayName() const override
Returns display name.
CompoundItem(const std::string &modelType=Constants::CompoundItemType)
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
virtual std::string displayName() const
Returns display name.
Definition: sessionitem.cpp:94
model_type modelType() const
Returns item's model type.
Definition: sessionitem.cpp:80
Defines class CLASS?
Defines class CLASS?
MVVM_MODEL_EXPORT int CopyNumber(const SessionItem *item)
Returns copy number of given item in it's parent hierarchy.
Definition: itemutils.cpp:49
materialitems.h Collection of materials to populate MaterialModel.