BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
SessionDecorationModel.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/View/Toplevel/SessionDecorationModel.cpp
6 //! @brief Defines class SessionDecorationModel
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
18 #include <QColor>
19 
21  : QIdentityProxyModel(parent)
22  , m_model(nullptr)
23 {
24  setSessionModel(model);
25 }
26 
28 {
29  QIdentityProxyModel::setSourceModel(model);
30  m_model = model;
31 }
32 
33 QVariant SessionDecorationModel::data(const QModelIndex& index, int role) const
34 {
35  if (role == Qt::ForegroundRole) {
36  QVariant result = textColor(index);
37  if (result.isValid())
38  return result;
39  }
40 
41  return QIdentityProxyModel::data(index, role);
42 }
43 
44 //! Returns text color. Disabled SessionItem's will appear in gray.
45 
46 QVariant SessionDecorationModel::textColor(const QModelIndex& index) const
47 {
48  QVariant result;
49 
50  if (SessionItem* item = m_model->itemForIndex(index)) {
51  if (!item->isEnabled())
52  return QColor(Qt::gray);
53  }
54 
55  return result;
56 }
Defines class InstrumentItem and all its children.
Defines class SessionDecorationModel.
Defines class SessionModel.
QVariant textColor(const QModelIndex &index) const
Returns text color. Disabled SessionItem's will appear in gray.
void setSessionModel(SessionModel *model)
QVariant data(const QModelIndex &index, int role) const override
SessionDecorationModel(QObject *parent, SessionModel *model=nullptr)
Base class for a GUI data item.
Definition: SessionItem.h:204
Base class for a GUI data collection. A collection is e.g. all real data (RealDataModel)....
Definition: SessionModel.h:42
SessionItem * itemForIndex(const QModelIndex &index) const