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

Description

Provides decorations (text color, icons, etc) for SessionModel in SessionModelView context. It is implemented as identity proxy model, so it has one-to-one data structure as in source SessionModel.

Definition at line 27 of file SessionDecorationModel.h.

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

Public Member Functions

 SessionDecorationModel (QObject *parent, SessionModel *model=nullptr)
 
QVariant data (const QModelIndex &index, int role) const override
 
void setSessionModel (SessionModel *model)
 

Private Member Functions

QVariant textColor (const QModelIndex &index) const
 Returns text color. Disabled SessionItem's will appear in gray. More...
 

Private Attributes

SessionModelm_model
 

Constructor & Destructor Documentation

◆ SessionDecorationModel()

SessionDecorationModel::SessionDecorationModel ( QObject *  parent,
SessionModel model = nullptr 
)
explicit

Definition at line 20 of file SessionDecorationModel.cpp.

21  : QIdentityProxyModel(parent)
22  , m_model(nullptr)
23 {
24  setSessionModel(model);
25 }
void setSessionModel(SessionModel *model)

References setSessionModel().

Here is the call graph for this function:

Member Function Documentation

◆ data()

QVariant SessionDecorationModel::data ( const QModelIndex &  index,
int  role 
) const
override

Definition at line 33 of file SessionDecorationModel.cpp.

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 }
QVariant textColor(const QModelIndex &index) const
Returns text color. Disabled SessionItem's will appear in gray.

References textColor().

Here is the call graph for this function:

◆ setSessionModel()

void SessionDecorationModel::setSessionModel ( SessionModel model)

Definition at line 27 of file SessionDecorationModel.cpp.

28 {
29  QIdentityProxyModel::setSourceModel(model);
30  m_model = model;
31 }

References m_model.

Referenced by SessionDecorationModel().

◆ textColor()

QVariant SessionDecorationModel::textColor ( const QModelIndex &  index) const
private

Returns text color. Disabled SessionItem's will appear in gray.

Definition at line 46 of file SessionDecorationModel.cpp.

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 }
Base class for a GUI data item.
Definition: SessionItem.h:204
SessionItem * itemForIndex(const QModelIndex &index) const

References SessionModel::itemForIndex(), and m_model.

Referenced by data().

Here is the call graph for this function:

Member Data Documentation

◆ m_model

SessionModel* SessionDecorationModel::m_model
private

Definition at line 39 of file SessionDecorationModel.h.

Referenced by setSessionModel(), and textColor().


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